Learn-to-send-email-via-google-script-html-no-server: Name of sender in mail-header

Created on 26 Aug 2017  Â·  6Comments  Â·  Source: dwyl/learn-to-send-email-via-google-script-html-no-server

hi..
In my case , everything works fine except one thing.
how can I place 'sender name' in the mail-from-header at the place of email address?
That is, when user will submit a form which has email and name both. I want name instead email in FROM field.
Is there any possible way to do so?

help wanted question

Most helpful comment

If I'm understanding this correctly, I think the you're looking for the MailApp's "name" parameter. That will actually change the name that appears in the user's inbox.

MailApp.sendEmail({   
  name: "Candy Store",
  to: TO_ADDRESS,
  subject: "New Order Submitted", 
  replyTo: String(mailData.email),
  htmlBody: formatMailBody(mailData)
});

The recipient will receive an email from "Candy Store" with the subject "New Order Submitted".

All 6 comments

You could check into the Mail API code to see if you can have stringed names, such as "John Doe john.doe@gmail.com", but I am unsure if that works. Otherwise, contacts in your mail client could be used. It may be possible to hook into that using an API as well, then you could add contacts automatically, but that is a little overkill probably.

thank you for your reply. i tried adding info such as "John Doe
john.[email protected]" but then mail stops being sent.

On Fri, Sep 1, 2017 at 4:26 AM, Sean McKenna notifications@github.com
wrote:

You could check into the Mail API code to see if you can have stringed
names, such as "John Doe john.[email protected]", but I am unsure if that
works. Otherwise, contacts in your mail client could be used. It may be
possible to hook into that using an API as well, then you could add
contacts automatically, but that is a little overkill probably.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/dwyl/html-form-send-email-via-google-script-without-server/issues/152#issuecomment-326442207,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AdfmXI_7xhmiVbn5iisfzfrGkZOFbrneks5sdzoygaJpZM4PDYaY
.

--
Thanks & Regards,
Falguni Thakkar.

I am not sure how to do this then without digging into the API.

If I'm understanding this correctly, I think the you're looking for the MailApp's "name" parameter. That will actually change the name that appears in the user's inbox.

MailApp.sendEmail({   
  name: "Candy Store",
  to: TO_ADDRESS,
  subject: "New Order Submitted", 
  replyTo: String(mailData.email),
  htmlBody: formatMailBody(mailData)
});

The recipient will receive an email from "Candy Store" with the subject "New Order Submitted".

thanks for sharing that solution @jakkrobbit !

If I'm understanding this correctly, I think the you're looking for the MailApp's "name" parameter. That will actually change the name that appears in the user's inbox.

MailApp.sendEmail({   
  name: "Candy Store",
  to: TO_ADDRESS,
  subject: "New Order Submitted", 
  replyTo: String(mailData.email),
  htmlBody: formatMailBody(mailData)
});

The recipient will receive an email from "Candy Store" with the subject "New Order Submitted".

thank you for the solution... :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThomasSalty picture ThomasSalty  Â·  4Comments

Herbert2122 picture Herbert2122  Â·  4Comments

ryanlao picture ryanlao  Â·  3Comments

mckennapsean picture mckennapsean  Â·  3Comments

joshiadvait8 picture joshiadvait8  Â·  3Comments