Home > front end >  Send an email on behalf a form submitter
Send an email on behalf a form submitter

Time:08-09

I have a form linked to a spreadsheet and every time a person submits a form, we track their email address. I also have a trigger when a user submits a form, it sends an email.

The problem is that all the emails are sent using my email address. I want to send that email using the form submitter email address. How can I achieve that.

I've been working with GmailApp.sendEmail() and as options I have:

let lastRow = ss.getActiveSheet().getLastRow();

const emailFrom = Sheets.Spreadsheets.Values.get("FILE_ID", `form responses!B${lastRow}:B${lastRow}`);

const options = {
    htmlBody: message,
    replyTo: data.email,
    cc: emailCc,
    'from': emailFrom 
  };

GmailApp.sendEmail(emailTo, subject, body, options)

CodePudding user response:

I think there is a typo in the code.

You should replace:

const options = {
    htmlBody: message,
    replyTo: data.email,
    cc: emailCc,
    'from': emailFrom 
  };

to:

const options = {
    htmlBody: message,
    replyTo: data.email,
    cc: emailCc,
    from: emailFrom
  };
  • Related