How to Send Emails from a Different Address (Alias) with Gmail

Say you have two email accounts - personal@gmail.com and work@company.com - the former is your personal email address while the latter is your work (corporate) email address. You are logged into your personal Gmail account but would like the mail merge to go out from your work account.

Consider another scenario where the personal secretary needs to sends out emails on behalf of her boss. So she runs the merge while staying logged into her own Google account but the recipients will see her boss’s email as the sender.

Both these scenarios can be easily handled in Mail Merge and Document Studio by setting up aliases in Gmail.

You can even send emails from your Outlook, Yahoo or Zoho email addresses through aliases in Gmail. Students and teach can send emails from their @school.edu email address while logged into their personal email accounts.

How to Setup Email Aliases in Gmail

Open gmail.com on your desktop computer, go to Settings, click the Accounts tab and, under the “Send mail as” section, click the link that says “Add another email address.”

Gmail Add Email Address

Next, follow the wizard to add the other email address as an alias to your current email address. You need to specify the sender’s name, the email address on behalf of which you wish to send out th emails and the reply-to address (optional).

Gmail Alias Setting

Treat as an alias - Yes or No?

If you own both email accounts, check the “treat as alias” option and emails sent to either address will arrive in the same Gmail inbox.

If you are sending emails on behalf on another person, say a secretary sending emails on behalf of his or her boss, the option should be unchecked. When the recipient replies to messages you send from the alias, the To: field in their reply message will be filled with your alias email address.

Gmail Verification

Gmail will send a verification code to your other email address that you wish to add as an alias to verify whether you really own or have access to that email account.

Verification Email Link

Log in to your other Gmail account and open confirmation email. Copy the confirmation code and paste it into alias verification box. Your other email address will now be added as an alias to your primary email address.

Change the Email Sender

This is how you can send emails from a different address in Google Sheets.

Mail Merge for Gmail

Send Email from Alias

Open your Google Sheet, choose Addons > Mail Merge with Attachments > Configure to open the merge sidebar. Expand the “Sender’s Email” dropdown and it will have a list of all email aliases that are connected to your Gmail account.

You can now send personalized emails on behalf of any email address that you own or have verified as an alias.

Document Studio

Open Google Sheet, go to Add-ons > Document Studio > Open. Expand the Mail Merge section and click on edit to open the Email Template designer. You’ll have an option to change the email sender as shown in the screenshot below:

Change Email Sender

Error - Cannot Add Aliases in Gmail

Are you getting an error while adding an alias in Gmail?

You must send through gmail.com SMTP servers you can send as abc@work.com. However, this functionality is not available for your account. Please contact your domain administrator.

If you do not see an option to add aliases in your Gmail settings, it is likely because your Google Workspace (GSuite) domain administrator has disabled the option to send email from aliases in domain settings.

To enable email sender aliases in Google Works, ask the admin to:

  1. Sign into the Google Admin console admin.google.com.
  2. From the dashboard, go to Apps > GSuite > Gmail > End User Access.
  3. Turn on the “Allow per-user outbound gateways” setting that says “Allow users to send mail through an external SMTP server when configuring a “from” address hosted outside your email domains.”

Save the settings and wait for about 30-60 minutes for the changes to propagate. You’ll then be able to added external email addresses as aliases in your Google Workspace email account.

Google Workspace Email Setting Send from a different email address in Google Workspace

How to Use a Different Reply-to Address in Gmail

With Document Studio, you can specify a different reply-to email address for outgoing email message. When the recipient hits the “Reply” or “Reply All” button, the To field in their email reply gets populated with the email address that you’ve specified as the Reply-to email at the time of sending.

You can even specify more than one email addresses in the reply-to field, separated by commas, and they will all show up in the To field of the reply field.

The reply-to addresses can also be dynamic and can be based on data in your Google Sheets and Google Forms. For instance, if you have a question in your Google Form that asks the form respondent’s email address, that email can be set as the reply-to address.

Thus, when you reply to the email message, the reply will automatically go to the form respondent’s inbox.

Reply-to Email Address for Gmail

To get started, open your Google sheet, go to the add-ons menu and choose Document Studio. Next click on the Open menu to open the Document Studio sidebar. Expand the Mail Merge section and click on visual email editor.

Reply-to email address

This opens the visual email template designer. Specify the address(es) in the Reply-to addresses field as shown in the screenshot.

If you are specifying a dynamic field, enclose the question title (or the column header) inside double curly braces like {{Email Address}}.

Troubleshooting: Gmail may not always send replies to the email address specified in the reply-to field. See solution - Gmail ignores reply-to setting.

How to Highlight Duplicates in Google Sheets and Remove

The Email Extractor app pulls emails addresses of your contacts from Gmail into a Google Sheet. You can then use Mail Merge or Document Studio to send personalized emails to your contacts from within the sheet itself.

That said, the imported mailing list may sometimes have duplicate email addresses and it is thus be a good idea to clean up the data in your Google Sheet by removing duplicates before sending out the emails.

Highlight Duplicates in Google Sheets

You can use Conditional Formatting in Google Sheets combined with the COUNTIF formula to quickly highlight cells that contain duplicate values.

Highlight Duplicates in Google Sheets

Here’s how you can find duplicates in Google Sheets:

  1. Open the Google Sheet containing your data and go to the Format menu.

  2. Select Conditional Formatting from the expanded menu. This will help us change the colors of cells, rows or columns that meet a specific criteria.

  3. In the Apply to Range input box, add the range of cells that contain possible duplicates. In our case, the email addresses are in column A so we can put A:A to specify the entire A column.

  4. Under the ‘Format cells if’ section, choose “Custom formula is” from the dropdown list as set the formula as =COUNTIF(A:A, A1) > 1

Click the Done button and you’ll instantly notice that all duplicate cells are highlighted as shows in the screenshot below.

Duplicate Cells in Google Spreadsheet

The COUNTIF Function

The COUNTIF function in Google sheets (and Microsoft Excel) essentially counts the number of cells in the range that meet a specific criteria. For instance =COUNTIF(A:A, "apple") will count the number of cells that contain the word apple.

It can accept wildcard characters too so =COUNTIF(A:A, "apple?") will count cells that contain the word apple or apples. Or say =COUNTIF(A:A, "*@gmail.com") and it will highlight all email address that end with a gmail address.

Please note that the COUNTIF function is case-insensitive so values like gmail.com and Gmail.com are seen as duplicates.

Highlight Entire Row Containing Duplicates

If you’ve noticed in the previous screenshot, only specific cells that have duplicate values are highlighted through conditional formatting.

However, if you would like the Google Sheet to highlight the entire spreadsheet row that contains duplicate values, we need to slightly tweak the formatting rule.

  1. Go to the Apply to Range input box and specify the entire spreadsheet range, not just the column that contains duplicates.

  2. In the custom formula,use absolute reference for the range and also change criterion to use $A1 instead of A1. When we use $A1, we are telling Google Sheet to only change the row but lock the column.

The new duplicate detection formula reads =COUNTIF($A$1:$C$50, $A1)>1

Highlight Duplicate Rows in Spreadsheet

Compare Multiple Columns for Duplicates

If you would like to determine duplicates by comparing data in multiple columns of the Google Sheet, use COUNTIFS instead of COUNTIF.

For instance, if column A is Email Address and column B is Company Name and you would like highlight duplicates cell only when the combination of values in Column A and B is identical, the new formula can be written as =COUNTIFS(A:A, A1, B:B, B1)>1

Remove Duplicate Rows in Google Sheets

Now that we have figured out a simple method to highlight duplicates in Google Sheets, the next task is to remove all duplicate rows.

There are two ways to go about it - either use Google Apps script or use the built-in feature of Google Sheets to remove duplicates.

First, highlight the entire column in Google Sheet that contains the duplicate data. Next, go to the Data menu and choose the Remove Duplicates option.

Select which columns to include and whether or not the selected range has any header row. Click Remove duplicates and your list is clean up in one go. Like with COUNTIF function, Google Sheets will ignore case and formatting when determining duplicates.

Remove Duplicate Rows

Remove Duplicates with Google Scripts

If you prefer automation, here’s a little snippet that will remove the duplicates in your active Google Sheet based on data in the first column.

/** @OnlyCurrentDoc */

function removeDuplicateRows() {
  SpreadsheetApp.getActiveSpreadsheet()
    .getActiveSheet()
    .getDataRange()
    .removeDuplicates([1]);
}

How to Enable Third-party Cookies in Google Chrome

The newer versions of Google Chrome block third-party cookies by default. Cookies are considered “bad” as they are mostly used for tracking users on the Internet but some cookies serve a useful purpose as well.

For instance, a GSuite add-on may open a small sidebar inside Google Sheets and this sidebar may need to communicate with other windows that are opened by the same add-on. Since the windows are on different domains, the only way for them to communicate with each other is through third-party cookies.

This video explains why some third-party cookies are necessary and how you can selectively allow cookies inside Google Chrome.

GSuite add-ons including Document Studio, Form Notifications and Mail Merge require you to enable third-party cookies in your browser to save user preferences and settings.

Allow Third-party Cookies for GSuite

Here are step-by-step instructions on how to enable third-party cookies in your Google Chrome browser. This will only allow cookies for GSuite add-ons in Google Sheets, Form, Docs, and Google Sides.

Step 1: Open Google Chrome browser, click the settings menu in the top right (3 vertical dots).

chrome settings menu

Step 2: Click the “Privacy and Security” option in the settings pane.

Settings Privacy

Step 3: Expand the “Cookies and other site data” section under the Privacy and Security page.

Block Third-party cookies

Step 4: The “Block third-party cookies” setting should be selected to continue blocking all cookies except those served by GSuite add-ons.

GSuite addon cookies

Step 5: Click the “Add” button under the section that says “Sites that can always use cookies” and enter the domain https://[*.]googleusercontent.com in the input box.

allow third party cookies

Click the “Add” button, reload your Google Form or Google Sheet and the addon will continue to work as before.

How to Generate PDF files from Google Form Responses

With Document Studio, you can easily generate PDF files, or document of any other file type, when someone submits your Google Form. The generated documents are stored in Google Drive, you can email them to the form respondent, share the file with team members or even print the documents via Google Cloud Print.

This step by step tutorial explains how to generate a PDF file from Google Form submissions.

Step 1: Create the Google Form

Go to forms.google.com and create a Google Form. We’ll build a Contact Us form that asks for the respondent’s name, email, postal address and comments.

google-forms-pdf.png

Go to the Response Tab, click the 3-dot vertical menu and select the response destination. The Google Form should be storing the responses in a Google Spreadsheet for the document merge add-on to work.

google-form-spreadsheet.png

Step 3: Create the Document Template

Build a new template using either Google Docs, Spreadsheet or Google Slide. We’ll create a one-page slide presentation with template {{markers}} corresponding to the various questions in our Google Form.

document-markers.png

Please ensure that the template markers in the document template are correctly mapped and that the marker name should be same as your form question. For instance, if you have a question in Google Forms that is titled “Your postal address?”, the marker name in the document template should read {{Your postal address?}}.

Step 4: Configure Document Studio

Open the Google Forms responses spreadsheet, go to the add-ons menu and choose Document Studio.

4a. Configure Document Template

Go to the Document Merge section and select the template you created in the previous step. You can also personalize the file name to include form answers.

4b. Configure Email Template

Open the Google Forms Merge section and design your email template. You can use can column header in the email subject and body using the {{marker}} notation. The merged document will be added to the email as an attachment. You can also choose the email field in the “Send Email” drop-down and the email will be sent to the form respondent.

email-template.png

Tip: If you would like to include all the form answers in the email, use the {{All Answers}} marker anywhere in the message body and it will be replaced with an HTML table containing all the form answers.

4c. Configure Google Drive

Your generated documents will be stored in Google Drive. Expand the “Upload to Google Drive” section and select the folder in Drive where the documents would be saved.  You can also customize the subfolder path with form answers so the form response files are stored in separate folders.

\\Comments\\{{Name}}

Step 5: Merge on Form Submit

The configuration is complete and we are ready to run the form submit trigger that will automatically merge documents and send the emails as soon as a new form is submitted.

google-form-submit.png

Go to the Save Configuration section, check the “Merge on Form Submit” option and click the Save Settings button. Now submit a test form entry and it should create the documents and send the emails.

GDPR Compliance

The General Data Protection Regulation (GDPR) is aimed at giving citizens throughout the European Union (EU) control over their personal data. GDPR applies to you if you are a European Union citizen or, as a business, if your email subscribers are EU citizens, or you deal with any kind of personal data of EU citizens.

How our add-ons enable you to comply with EU’s GDPR policies

As a customer, you operate as the data controller and we are considered a data processor. You have the responsibility for ensuring that the personal data of subjects you are collecting is being processed lawfully and, similar to controllers, processors, that processes personal data on behalf of a data controller, are expected to comply with the GDPR.

Data Collection

With GDPR, you must have explicit consent from your email subscribers that they would like to receive emails from you. It is recommended that you use double opt-in to align with GDPR compliance requirements. For EU individuals who are already on your marketing lists, you may need to contact them by email asking them to confirm their consent.

You should include a visible unsubscribe link in your marketing emails that your subscribers can click to instantly unsubscribe from all your future communications.

Data Storage and Processing

All your customer’s data is stored in your Google account, inside Google Sheets, Docs, Gmail, Google Drive or Google Forms and not on our servers. Our addons read the data directly from your data source and perform the necessary actions (like sending emails, generating documents, saving emails) without transferring any personal data.

The email messages are not stored on our servers. If you choose to attach Google Drive files in your emails, the content of the files are not stored on our servers. Your form submissions are not stored on our servers. If you enable optional campaign tracking (opens, clicks, unsubscribes), the email addresses of recipients, unsubscribers, and bounced emails are stored in the database for reporting.

We store and process user data in Google Cloud database (us-east) and its servers are located in the United States (East) data center.

We use Google’ Stackdriver logging tool for error tracking and debugging errors. It includes stack traces, error messages and the logs do not include any PII data.

We use PayPal, Stripe, and Paddle to manage your payments. The payment processors only provide the customer’s email address and, in case of PayPal, the shipping address for generating invoice. We do not have access to any banking or credit card information of our customers.

Data Portability

We do not transfer, sell, make copies, or share any of your data processed by our Google Add-ons to third party services or companies. We only store data that is absolutely necessary for our add-ons to function.

You can use download and export all your subscriber’s information in Google Sheets. This allows for easier migration to other services.

Data Erasure (Right to be forgotten)

All addons have a deactivate option that will permanently delete all user’s data from the database. You can also contact us to submit a deletion requires and, in compliance towards GDPR, we’ll permanently delete all your data.

If you uninstall a Google Addon, or revoke access to the addon from your Google Account, the add-on will not be able to access any of your data and will instantly stop functioning.

Our Google Addons use your own Gmail account to send emails. You can feed your customer profile data directly into our Google Add-ons - through Google Sheets and Google Forms - to send marketing emails, transaction emails and form notifications. Our tools only facilitate your compliance to GDPR, your sending practice is key to complying with GDPR.

Contact Us

If you have any questions, please contact us by email: amit@labnol.org

How to Use Template {{Markers}} in Document Studio

Your Document Studio templates can include any variable field that is available as a column title in the Google Sheet. In case of Google Forms, you can use any question title as your marker and the marker should be exactly as your question title enclosed in double curly braces.

For instance, if a question in your Google Form says “What is your name”, the marker you’ll use in your document template will be {{What is your name}}.

You can also create additional columns in the source Google Spreadsheet with formulas and use them as dynamic markers in your Google template. Let me show you an example.

Create a new column and call it Row Number. Now go to the first empty cell of that column and put this ArrayFormula function:

=ArrayFormula(if(LEN(A2:A); row(A2:A) -1;))

What we have added a column that displays the row number of the rows and we can now put {{Row Number}} in your document templates, merged file names and Drive folder path. For instance, if you put Invoice #{{Row Number}} in the file name, the files name would be named Invoice #1, Invoice #2 and so on automatically.

Formatting Date and Time

The same technique can be used to format date and time information for including in your templates.

Say the first column in your Google Sheet in called Timestamp and it includes the date and time when a Google Form response was submitted. Add a new column called Submission Time and add this formula in the first empty cell.

=ArrayFormula(if(NOT(ISBLANK(A2:A)),HOUR(A2:A)&":"&MINUTE(A2:A),))

You can now include the submission time in your email and document template using the {{Submission Time}} variable field.

Standard Markers for Google Forms

In addition to standard form questions and column headers, Google Forms also support a few standard markers like:

  • {{Response Number}} - Form Response number
  • {{Form Name}} - The name of the Google Form
  • {{Form Url}} - A link to the associated Google Form
  • {{Response Id}} - Unique response ID generated by Google Form
  • {{Response Url}} - Directly link to view / edit the current form submission
  • {{Response Date}} - The full timestamp when a form was submitted
  • {{Respondent Email}} - If your Google Form is capturing email addresses, this will include the email address of the form respondent.
  • {{All Markers}} - An HTML table containing all the form responses in a neat tabular format.

You should put {{All Answers}} in your email body to receive a copy of the form answers in an email notification.

Google Docs PDF Export Adds Extra Blank Pages at the End

Say you have a document created inside Google Docs that is exactly two pages long. However, when you print or export the document as a PDF file, a few extra blank pages are inserted at the end of the document.

You may not have an extra lines or white spaces after the last line of text and yet the blank pages may be added. Here’s a sample PDF with multiple blank pages insert in the end by Google Docs.

Screenshot 2018-07-02 at 12.55.24 PM.png

To confirm if your Google Document is affected by this issue, open the file inside Google Docs, go to the File menu and choose Print Preview. If any blank pages are added to your document in the print preview, they will show up in the exported PDF as well.

This is a very old bug in Google Docs and there are a few solutions you can try to get around the problem.

1. Turn on Print Layout - Open the document in Google Docs, go to the View menu and enable Print Layout. Now if you export the same document as a PDF file, you most likely won’t see the extra pages.

print-layout.png

2. Change Margins - If the print layout option doesn’t resolve the problem, you may try changing the margins of the document.

Go to the File menu in Google Docs, choose Page Setup and here lower the margins. You may also try changing the page size from say A5 or Letter to A4. Click OK to apply the changes and export as PDF again to test if this resolve the issue.

3. Start from Scratch - If your problem is not resolved, open the Google Document, press Ctrl-A (or Cmd-A) to select the entire document, Ctrl-C to copy it to the clipboard, then create a new document and paste the content with Ctrl-V. The new document may not be affected by the PDF bug.

Document Studio uses the same PDF rendering engine of Google Docs to convert your document templates into PDF files. If you notice any blank pages in your exported PDF files, make sure the “Print Layout” setting is checked in the source document template.