Use of cc and/or bcc in google apps script MailApp

2019-07-20 19:28发布

I am running the following script in Google apps script (emailAddress is a variable pulled from a sheet):

MailApp.sendEmail(emailAddress, subject, message,{htmlBody:message});

I am trying to add a cc and/or bcc string to this, but when I do so (and I using the correct format) I am getting a consistent error that there are too many strings when I do so.

Is MailApp.sendEmail limited to only four strings? Is my use of the {htmlBody:message} the problem? I was able to partially achieve what I am trying to do by eliminating this, but my goal is to send an html email out and copy that email to an internal address so all my staff can see the sent email, rather than only the sender.

Another issue is that I do not want the following

var emailSent = row[5];
if (emailSent != "EMAIL_SENT")

to operate on the cc'd and/or bcc'd email or my source sheet will include two EMAIL_SENT entries for every email.

Is there a solution?

1条回答
孤傲高冷的网名
2楼-- · 2019-07-20 20:22

Please try this:

MailApp.sendEmail(emailAddress, subject, message, {
  htmlBody: message,
  cc: 'internal1@email.com',
  bcc: 'internal2@email.com'
});

There are other parameters also available check here : https://developers.google.com/apps-script/reference/mail/mail-app#sendemailrecipient-subject-body-options

查看更多
登录 后发表回答