Google Apps Script sendEmail: multiple recipients string? -


using sendemail, how can send email multiple comma-separated recipients combining 2 form fields? seems work when (lastrow,4) has 1 value (abc@domain.com) not more 1 (abc@domain.com, xyz@domain.com). current code below, , variable in question recipientsto.

function formemail() {   var ss = spreadsheetapp.getactivespreadsheet();   var sheetform = ss.getsheetbyname("sheet1"); // name of sheet contains results   var lastrow = sheetform.getlastrow();   var recipientsto = sheetform.getrange(lastrow,3).getvalue() + "@domain.com";   var recipientscc = ""   var team = sheetform.getrange(lastrow,5).getvalue();   var datestamp = utilities.formatdate(sheetform.getrange(lastrow,1).getvalue(), "gmt - 5", "yyyy-mm-dd");   var html = "intro text;    //the questions order in email order of column in sheet       (var = 2; < 11; ++i) {     html = html + "<b>" + sheetform.getrange(1,i).getvalue() + "</b><br>";     html = html + sheetform.getrange(lastrow,i).getvalue() + "</p><br>";        }    //add additional emails if entered in form field   if (sheetform.getrange(lastrow,4).getvalue() !== "") {     recipientsto = recipientsto + "," + sheetform.getrange(lastrow,4).getvalue()   }    //cc if response question "yes"   if (sheetform.getrange(lastrow,10).getvalue() == "yes") {     recipientscc = "ccemail@gmail.com"   }     mailapp.sendemail({     to: recipientsto,     cc: recipientscc,     subject: "subject",     htmlbody: html, });   } 

according sendemail(message) documentation, field has 1 recipient. whereas cc field can have multiple recipients separated comma.

http://goo.gl/cgjij

`to - string - address of recipient.

cc -string - comma separated list of email addresses cc`

another option use sendemail(string,string,string,object) in function "recipient string addresses of recipients, separated commas".

hope helps.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -