title: Google Apps Script sendEmail: multiple recipients string?
body: <p>Using sendEmail, how can I send an email to multiple comma-separated recipients by combining two form fields? It seems to work when (lastrow,4) has only one value (abc@domain.com) but not for more than one (abc@domain.com, xyz@domain.com). Current code is below, and the variable in question is <strong>recipientsTo</strong>.</p>
  
  <pre><code>function FormEmail() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheetform = ss.getSheetByName("Sheet1"); // Name of the sheet which contains the 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 the email will be the order of the column in the sheet  
      for (var i = 2; i &lt; 11; ++i) {
      html = html + "&lt;b&gt;" + sheetform.getRange(1,i).getValue() + "&lt;/b&gt;&lt;br&gt;";
      html = html + sheetform.getRange(lastrow,i).getValue() + "&lt;/p&gt;&lt;br&gt;";
         }
  
    //Add additional emails if entered in form field
    if (sheetform.getRange(lastrow,4).getValue() !== "") {
      recipientsTO = recipientsTO + "," + sheetform.getRange(lastrow,4).getValue()
    }
  
    //CC if response to a question is "Yes"
    if (sheetform.getRange(lastrow,10).getValue() == "Yes") {
      recipientsCC = "ccEmaIL@gmail.com"
    }
  
  
    MailApp.sendEmail({
      to: recipientsTO,
      cc: recipientsCC,
      subject: "Subject",
      htmlBody: html,
  });
  
  
  }
  </code></pre>