title: Send emails via app script with varying names in the HTML body
body: <p>I've gotten myself hopelessly lost in this one.</p>
  <p>I had this working with just information from one spreadsheet to the script, but I wanted to format the email with my email's signature and that lead to making the whole email HTML instead. (I understand there's some kind of API for that but I couldn't get to work.)</p>
  <p>Unfortunately, if I send out a mass email with this code through gmail, it threads everything together into one massive conversation and I need them to be individual emails.</p>
  <p>I am hoping that I can get the Name variable into the HTML text so that every email is different and maybe it won't thread itself together.</p>
  <p>This is the apps script</p>
  <pre><code>function getEmailHtml() {
    var htmlTemplate = HtmlService.createTemplateFromFile(&quot;Template.html&quot;);
    var htmlBody = htmlTemplate.evaluate().getContent();
    return htmlBody;
  }
  
  function sendEmail() {
  
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var emailData=ss.getSheetByName('Emails');
  var subject = emailData.getRange(2,1).getValue(); //subject line
  var n=emailData.getLastRow();
  for (var i = 2; i &lt; n+1 ; i++ ) {
  var emailAddress = emailData.getRange(i,3).getValue(); // recipient's email
  var name = emailData.getRange(i,2).getValue(); // recipient's name
  
  var htmlBody = getEmailHtml();
  
    MailApp.sendEmail({
      cc: &quot;example@gmail.com&quot;, //cc manager
      to: emailAddress,
      subject: emailsubject,
      htmlBody: htmlBody 
    });
  }
  
  }
  </code></pre>
  <p>The (mostly relevant) HTML</p>
  <pre><code>&lt;div dir=&quot;ltr&quot;&gt;
      &lt;div style=&quot;color:#222222;font-family:Arial,Helvetica,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:#ffffff;text-decoration-style:initial;text-decoration-color:initial&quot;&gt;Hi there  !&lt;/div&gt;
  </code></pre>
  <p>I would like to have the person's name be placed after &quot;Hi there&quot;
  There's more to the email after that but this is the only spot that needs the name.</p>
  <p>I've tried scouring the various posts about pushing variables to HTML but I've gotten frustrated enough with this mess that I admit defeat.</p>