有没有办法更改通过 Google Apps Script 发送的电子邮件中的显示名称?

MrG*_*les 4 email google-apps-script

我正在测试从 Google Apps Script 发送的电子邮件,它使用电子邮件地址的显示名称(@ 之前的部分)发送电子邮件。

这是一个公司地址,如:info@example.com,显示的只是“信息”。

我想让它像:“来自 Example.com 的 Bob”

有没有办法在 App Script 中做到这一点?我已将其设置为手动发送电子邮件。

提前致谢。我无法从 Google 搜索中找到帮助。

Fau*_* R. 5

是的,您可以使用类sendEmail方法的高级参数来做到这一点GmailApp

name是您要查找的参数。这是 Google 提供的代码示例。

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

在此处查找更多详细信息 - https://developers.google.com/apps-script/reference/mail/mail-app#sendEmail(String,String,String,Object)