title: MailApp AppScript: How to send an email to a thread using MailApp?
body: <p>I am using <a href="https://developers.google.com/apps-script/reference/mail/mail-app" rel="nofollow noreferrer">mailApp class</a> of Appscript to send daily emails as shown below:</p>
  <pre><code>MailApp.sendEmail({to: emails[0],subject:subjectLine,htmlBody: htmlContent,cc: emails.slice(1,emails.length).join(&quot;,&quot;)});
  </code></pre>
  <p>What I observe is that for <code>subjectline = &quot;TestEmail&quot;</code> if sent more than once it gets sent to a new thread:</p>
  <p><a href="https://i.stack.imgur.com/pQ971.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pQ971.png" alt="Example Image" /></a></p>
  <p>What I actually want is to instead of MailApp creating a new thread, it must send it to the old thread if the subject line is the same. Like for example: <code>subjectline = &quot;TestEmail&quot;</code> then all the mails within this subject should fall under the same and not dispersed as shown above. And only when the subject line changes they should fall into a new email thread.</p>
  <p>Has anyone faced the same problem? Does anyone know any work around for the same? Please let me know if you have a solution for the same.</p>
  <p>Thanks in Advance.</p>