MailApp: Dynamic variables in CC and BCC mail is not working

后端 未结 1 1299
伪装坚强ぢ
伪装坚强ぢ 2021-01-28 22:13

I am trying to automated emails. I have a query in google sheets that displays me all cases where an email has to be sent. The for loop collects the corresponding customer name,

相关标签:
1条回答
  • 2021-01-28 22:47

    Answer:

    You need to use the sendEmail(recipient, subject, body, options) method with the BCC and CC in the options parameter.

    More Information:

    As per the documentation:

    sendEmail(recipient, subject, body, options)

    Sends an email message with optional arguments.

    And in the Advanced parameters section:

    bcc String: a comma-separated list of email addresses to BCC

    cc String: a comma-separated list of email addresses to CC

    Code Modification:

    MailApp.sendEmail({to: currentEmEmail, 
            subject: subjectLine, 
            htmlBody: messageBody, 
            cc: "p........@......",
            attachments: [file1, file2]});
    

    Should be:

    MailApp.sendEmail(currentEmEmail, subjectLine, messageBody, {
      cc: "p........@......",
      name: 'Automatic Emailer Script',
      attachments: [file1, file2]
    });
    

    I hope this is helpful to you!

    References:

    • Class MailApp | Apps Script | Google Developers
    0 讨论(0)
提交回复
热议问题