5

I'm testing email sent from Google Apps Script and it's sending it with the display name of the email address (the part before the @).

It's a business address like: info@example.com and all that is showing is "info".

I would like to make it like: "Bob from Example.com"

Is there any way to do this in App Script? I have it set up for manually sent emails.

Thanks in advance. I couldn't find help from a Google search.

MrGreggles
  • 6,113
  • 9
  • 42
  • 48
  • A generic example from what works (shows "Bob from Example Ltd" as sender): GmailApp.sendEmail(emailAddress, subject, body, {'bcc':'info@example.com', 'name':'Bob from Example Ltd', 'htmlBody':'

    Hi ' + firstName + ',

    Just a little update to let you know that we have your job planned for ' + targetDate})

    – MrGreggles Apr 21 '14 at 18:37

1 Answers1

7

Yes, you could do that with the advanced parameters of sendEmail method of GmailApp class.

name is the parameter you are looking for. Here is the code sample that Google provides.

MailApp.sendEmail('mike@example.com', 'Attachment example', 'Two files are attached.', {
    name: 'Automatic Emailer Script',
    attachments: [file.getAs(MimeType.PDF), blob]
});

Find more details here - https://developers.google.com/apps-script/reference/mail/mail-app#sendEmail(String,String,String,Object)

Shan Eapen Koshy
  • 2,909
  • 1
  • 28
  • 40
Fausto R.
  • 1,314
  • 3
  • 16
  • 29
  • This does not address the case where multiple different users want to use this script, and want to have their names be uniquely identified. – Mahmoud Maarouf Jul 02 '21 at 03:53