1
votes

Romain Vialard and labnol did a great job with the scripting for a mail merge for gmail: http://www.labnol.org/internet/personalized-mail-merge-in-gmail/20981

The script lets you indicate whether or not you want to be BCC'd on all the emails sent. It assumes the email address to include in BCC is the one you are sending from.

How can the script be changed to allow me to BCC a different email address, not just the one i'm sending from?

In other words, I want to be able to input any email address to BCC, such as "emailtosalesforce@n-xvh0q8 2w.31ghxkeac.3.le.salesforce.com"

Why: I am a user of Salesforce.com, and one simple way to automatically log emails in the online system is to BCC an "Email To Salesforce.com" address, such as "emailtosalesforce@n-xvh0q8 2w.31ghxkeac.3.le.salesforce.com".

4

4 Answers

0
votes

You can put this email address as BCC in the script itself. Are you using "Yet another mail merge", available in the Apps Script Gallery ?

If you open your spreadsheet and click on Tools > Script Editor, you can edit the script. Search for "bcc" in the script and add the email address you want to use as bcc.

eg: bcc: "emailtosalesforce@n-xvh0q8 2w.31ghxkeac.3.le.salesforce.com"

Take a look at the documentation for more explanations: https://developers.google.com/apps-script/class_gmailapp#sendEmail

0
votes

If you're using "Yet another mail merge," perform a search for bcc. Where the code reads "bcc = (e.parameter.addMeAsBCCCheckbox == 'true') ? user : ''" replace "e.parameter.addMeAsBCCCheckbox == 'true') ? user : ''" with the email address you want to bcc to. Make sure you check the "I want to receive a copy of each email sent"

The final code should look like this:

    function startStandardMerge_(e) {
    var kind = (e.parameter.items == null) ? 'gmail' : 'docs';
    var selectedTemplate = GmailApp.getThreadById(e.parameter.chosenTemplate).getMessages()[0];
    var user = Session.getEffectiveUser().getEmail();
    var bcc = "EMAIL ADDRESS YOU WANT TO BCC TO";
    var name = e.parameter.chosenName;
    var from = e.parameter.chosenFrom;
    merge(kind, selectedTemplate, name, from, bcc);
0
votes

This feature is built in to "Yet another mail merge". Add a column named "bcc" to your spreadsheet and it will automatically be used in the email's bcc field.

0
votes

Old version required you to modify script/bcc section in script editor, not case anymore using "Yet another mail merge". Just add column named "bcc" to spreadsheet (as mdahlman advised). Works perfect. Note: did not show email was BCCed in outbox, but it worked (I used unique bcc email for email-to-salesforce, and it logged just fine).