Create a Mail Merge With Gmail and Google Docs

  • Published on
    28-Nov-2014

  • View
    53

  • Download
    0

Transcript

Create a Mail Merge with Gmail and Google Docshttp://www.labnol.org/software/mail-merge-with-gmail/13289/ Lets say you are organizing a party at your place and want to send personalized email invitations to all your friends. Or say your company is about a launch a new product and you want to share this with media and customers through email. In both the above examples, all your email messages will essentially have the same content but some elements will be unique (like the recipient's name) in every copy. For instance, when you are sending a casual email to friends, you might want to have Hi [Friendss nickname] as the greeting while in the case of customers, you will prefer a more formal greeting with their first names

How to Create Mail Merge with Google Mailhttps://www.youtube.com/watch?v=El_KTbJHEXgMail Merge can obviously save you plenty of time as you can send personalized email messages to multiple people at once. The feature is neither available in Gmail nor Google Apps but there are workarounds like: Option #1. You can connect your Gmail account with Outlook and then use the Mail Merge feature of Microsoft Office Word to send bulk email messages through Gmail but from your desktop. Option #2. You can use web based services like MailChimp, Constant Contact, Campaign Monitor, etc. for sending personalized mass emails but they arent free. If none of the above options work for you, heres a third and better solution you can setup Mail Merge in Gmail through your Google Docs account its both free and easy to setup. Lets get started.

Mail Merge - Step by StepStep 1: Assuming that your already have a Gmail account, go to your Google Contacts and create a new Group (lets say Media). Add all the contacts to this group who you want to send a personalized email. Step 2: Create a copy of this spreadsheet i(http://goo.gl/6i13a) nto your own Google Docs account. Step 3: Youll see a new Mail Merge menu in Google Docs near Help. Click Import Gmail Contacts and authorize Google Docs to access your Google Contacts. Step 4: Click Mail Merge > Import Gmail Contacts again and type the name of the Gmail group (Media) that you created in Step 1. Google Docs will now automatically import the relevant Gmail contacts into the spreadsheet.

Step 5: Fill the various fields of the email template (highlighted in green). Change the email subject, email body (line 1-5), fill in your name and also the reply-to email address. Step 6: Go to the Mail Merge menu again and click Start Mail Merge the status against the names of your Gmail contacts will change from Pending to OK for all email messages that are successfully delivered through Google Docs. Thats it! Youve just completed your first mail merge through Gmail and Google Docs. Related tutorial: Setup Mail Merge with File Attachments

Custom Email Templates for Mail MergeIf you would like to use a different email template with mail merge, you can go to Tools > Scripts > Script Editor and change the sendEmail() function accordingly. Heres the full source code of the macro that runs on the Mail Merge spreadsheet but before you make any changes, please read this section to get yourself familiar with the Google Docs scripting environment. Google Docs also supports file attachments and HTML emails so you can be more creative with your email templates. I have used this in batches of 10-20 email addresses and that has worked without issues but Im not sure if the Gmail sending limit (that can temporarily lock accounts) applies to Google Docs or not. Also, the above spreadsheet uses Gmail but you can also use it with Yahoo! Mail or your Windows Live Hotmail contacts.

http://www.labnol.org/internet/google-docs-macro-code/13291/function onOpen() { var mySheet = SpreadsheetApp.getActiveSpreadsheet(); var menuEntries = [ {name: "Step 1: Import Gmail Contacts", functionName: "importContacts"}, {name: "Step 2: Start Mail Merge", functionName: "sendEmail"}, {name: "Help / About", functionName: "showHelp"}]; mySheet.addMenu("Mail Merge", menuEntries); } function importContacts() { var groupName = Browser.inputBox("Enter the name of your Gmail Contacts group here:"); var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var myContacts = ContactsApp.findContactGroup(groupName).getContacts(); for (i=0; i < myContacts.length; i++) { var myContact = [[myContacts[i].getFullName(), myContacts[i].getPrimaryEmail(), "Pending"]]; mySheet.getRange(i+2, 1,1,3).setValues(myContact); }

Browser.msgBox("You have successfully imported " + myContacts.length + " contacts from Gmail. Please proceed to Step 3."); } function sendEmail() { var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var newLine = "

"; var emailSubject = mySheet.getRange("F2").getValue(); var emailSalutation = mySheet.getRange("F3").getValue(); var emailLine1 = mySheet.getRange("F4").getValue() + newLine; var emailLine2 = mySheet.getRange("F5").getValue()? mySheet.getRange("F5").getValue() + newLine : ""; var emailLine3 = mySheet.getRange("F6").getValue()? mySheet.getRange("F6").getValue() + newLine : ""; var emailLine4 = mySheet.getRange("F7").getValue()? mySheet.getRange("F7").getValue() + newLine : ""; var emailLine5 = mySheet.getRange("F8").getValue()? mySheet.getRange("F8").getValue() + newLine : ""; var emailBody = emailLine1 + emailLine2 + emailLine3 + emailLine4 + emailLine5; var emailSignature = mySheet.getRange("F9").getValue() + newLine; var emailYourName = mySheet.getRange("F10").getValue(); emailBody = emailBody + emailSignature + emailYourName + "
"; var emailReplyTo = mySheet.getRange("F11").getValue(); var myContacts = mySheet.getDataRange(); var myContact = myContacts.getValues(); for (i=1; i < myContact.length; i++) { var person = myContact[i]; if (person[1] != "" && person[2] != "OK") { var emailMsg = emailSalutation + " " + person[0] + "," + newLine + emailBody; var advancedArgs = {htmlBody:emailMsg, name:emailYourName, replyTo:emailReplyTo}; MailApp.sendEmail(person[1], emailSubject, emailMsg , advancedArgs); mySheet.getRange(i+1,3).setValue("OK"); } } SpreadsheetApp.flush(); } function showHelp() { Browser.msgBox("With Mail Merge, you can send personalized email messages to your Gmail contacts in two easy steps. For help, visit http://labnol.org/?p=13289 or send me a tweet @labnol."); }

Google Apps Script Overview https://code.google.com/googleapps/appsscript/guide.html

Recommended

View more >