【问题标题】:Is there a way to change the display name in email sent via Google Apps Script?有没有办法更改通过 Google Apps 脚本发送的电子邮件中的显示名称?
【发布时间】:2014-06-05 11:58:05
【问题描述】:

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

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

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

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

提前致谢。我无法通过 Google 搜索找到帮助。

【问题讨论】:

  • 一个通用示例(显示“示例有限公司的 Bob”作为发件人):GmailApp.sendEmail(emailAddress, subject, body, {'bcc':'info@example.com', ' name':'Bob from Example Ltd', 'htmlBody':'

    Hi ' + firstName + ',

    稍微更新一下,让您知道我们已经为您计划了的工作' + 目标日期})

标签: email google-apps-script


【解决方案1】:

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

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

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

在此处了解更多详情 - https://developers.google.com/apps-script/reference/mail/mail-app#sendEmail(String,String,String,Object)

【讨论】:

  • 这并没有解决多个不同用户想要使用这个脚本,并希望他们的名字被唯一标识的情况。
猜你喜欢
  • 2013-08-15
  • 1970-01-01
  • 2020-12-15
  • 1970-01-01
  • 1970-01-01
  • 2018-02-05
  • 2023-03-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多