Search code examples
google-apps-scriptgoogle-sheetsgoogle-forms

GmailApp.sendEmail() Add reply to address


I have this code from my google script app the code sends an email to a recipient every time a user submits the form.

function LeadNotifier(e) {

 var values = e.values;
  var htmlBody = '<div background:#E5E8E8;><h2 style="color:#154360;">MENSAJE WEB E.LUCIANA<h2><ul>';
  for (var i=0; i < values.length; i++) {

    var data = values[i];
    htmlBody += '<li>' + ": " + data + '</li>';
  };
  htmlBody += '</ul><h3 ><strong style="color:green;" >Web Site:</strong> Edificio Luciana</h3></div>';
  GmailApp.sendEmail('[email protected]','Cotización de Departamento','',       {htmlBody:htmlBody});
   GmailApp.sendEmail("[email protected]","[email protected]","TPS report status",{htmlBody:htmlBody});

}

But now my client wants to add the user's email as a reply-to so they don't have to fill that field when they respond to customers.

is there a way to achieve this?


Solution

  • According to the documentation, you can set the replyTo field in the options.

    GmailApp.sendEmail("[email protected]", "Subject", "Body", {
      htmlBody: htmlBody,
      replyTo: "[email protected]"
    });