I have a script behind a Google spreadsheet that sends an email once certain cells of a row is completed. The script works by sending to multiple hard coded email addresses. How can I add the current user's email address as a 2nd CC? One of the CC is hard coded but the 2nd changes depending on the person updating the spreadsheet. I know how to grab the email address but how do I pass it as a variable so it actually gets CC-ed?
var currentemail = Session.getActiveUser().getEmail();
var options = {cc: 'Session.getActiveUser().getEmail(), someotheremail@domain.com'};
or
var options = {cc: 'currentemail, someotheremail@domain.com'};
GmailApp.sendEmail(email, subject, body, options);
Obviously these do not work :)
Many thanks in advance
this can be done like below :
function sendWithCc(){
var currentemail = Session.getActiveUser().getEmail();
var options = {};// create object
options['cc'] = currentemail+',someotheremail@domain.com';// add key & values (comma separated in a string)
GmailApp.sendEmail('somemail@domain.com', 'subject', 'body', options);
// I stringified 'subject' and 'body' to make that test work without defining values for it
}