A simple Google Sheets mail merge tool using Google Apps Script. This tool combines the power of Drive, Sheets and Gmail into one mighty little mail merge tool.
This script automates two processes: 1) A folder link iterator & 2) A mail merge.
-
The link iterator will extract the all of the file links from a Drive folder. It allows you to paste in the URL of a Google Drive folder with all of the docs you want to grab the links from.
-
After you've added the names and emails to the sheet, the mail merge will send out an email with the linked file as a PDF attachment.
In order to use the script, you need to add two files to your Sheets workbook. To begin, click on Script Editor from the Tools tab.
This will open up the Google IDE where you will delete the sample JS data in the Code.gs tab...
...and replace it with the code from GASmerge Code.gs. Be sure to save!
Next, create a new HTML file under the File tab.
Be sure to name the new HTML file "Sidebar".
Again, delete the sample HTML code and replace with the GASmerge Sidebar.html code and save.
Once you have saved both files, you are ready to use GASmerge!
When you install this script, a new "Sidebar" tab will be added to the Sheets menu.
But in order to access the Sidebar, you will need to authorize the script to access the data. When you open the Sidebar for the first time, you may see an Authorization prompt like this.
Because this is a script that you are installing yourself (instead of buying an officially verified third-party script) you will need to acknowledge this fact by clicking on "Advanced"...
...then scroll down to the bottom and click on "Go to Untitled project (unsafe)".
This will bring up another screen asking you to verify that you are allowing the script to access your Drive (for the attachments), Sheets (for the merge data) and Gmail (for sending the emails). There is no third party info used in the script, but it does warn you that the script could include it (if you modified the script to do so). To proceed, you must click the "Allow" button.
Once you have finished that, you're ready to go!
To open the Sidebar, you may need to refresh the workbook page on your browser. Once the Sheets workbook has been refreshed you can click on the Sidebar dropdown from the Sidebar tab.
That will open up the Sidebar.
To list the PDF files you will be using as attachments, paste the URL of the Drive folder containing the PDFs into the input box in the Sidebar, then push the "Get the Links" button. The Drive folder should look something like this.
The script will create a new sheet in your workbook...
...and add hyperlinks for all of the documents it finds in the Drive folder.
Next, add the names and email addresses of the contacts that will receive each of the files listed. (Be sure to distinguish multiple email addresses by using a comma separator).
Finally, push the "Send Email" button when ready to send. The script will update each row as it sends the emails.