Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 639
jon_win Avatar asked Mar 29 '18 14:03

jon_win


Video Answer


1 Answers

Please try this:

MailApp.sendEmail(emailAddress, subject, message, {
  htmlBody: message,
  cc: '[email protected]',
  bcc: '[email protected]'
});

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

like image 114
Umair Mohammad Avatar answered Oct 20 '22 13:10

Umair Mohammad