【问题标题】:Google Apps Script - Sending email with Gmail SignatureGoogle Apps 脚本 - 发送带有 Gmail 签名的电子邮件
【发布时间】:2018-02-05 07:18:59
【问题描述】:

我是 GAS 和 Gmail API 的新手,并尝试使用带有 Gmail API 的 Google Apps 脚本触发来自 Google 电子表格的电子邮件。

我的问题是,是否可以在电子邮件中包含用户的 Gmail 签名后发送电子邮件?

所以我想知道我是否可以从我的 Gmail 帐户访问我的签名并连同它一起发送电子邮件。是否可以使用 Gmail API 和应用程序脚本?

这是我到目前为止所得到的。

https://developers.google.com/admin-sdk/email-settings/#manage_signature_settings - 已弃用,因此下面的链接应该可以工作

https://developers.google.com/gmail/api/v1/reference/users/settings/sendAs

从上面的链接我想我应该使用 sendAs 资源。不知道如何触发电子邮件。

如果有人可以向我展示使用包含签名的 Google Apps 脚本和 Gmail API 的测试电子邮件,我将不胜感激。电子邮件可以是纯文本。

再次感谢。 我真的很需要这个。请帮帮我。

【问题讨论】:

  • 您现在使用什么代码来触发电子邮件?在您的工作表中,您将使用GmailApp 类而不是MailAppMore here on using the Gmail API in Spreadsheets.
  • 感谢布赖恩的回复。我通常使用 GmailApp 或 MailApp 之类的东西.. MailApp.sendEmail(to, subject,'',{htmlBody: body, cc:''+cc , bcc: ''+bcc});但是这样我也可以包含我的 Gmail 签名吗?如果这是可能的,那么我的问题就解决了。
  • 知道了。所以,不,您不能从标准的GmailApp 类访问签名。您需要在下面的答案中使用高级 Google 服务。

标签: google-apps-script gmail-api


【解决方案1】:

docs看来确实是可以的。

要更新,您需要向该资源发送 PUT 请求:

输入https://www.googleapis.com/gmail/v1/users/userId/settings/sendAs/signature 其中userId 是您的用户标识ID,signature 是下面列表中的设置之一

{
  "sendAsEmail": string,
  "displayName": string,
  "replyToAddress": string,
  "signature": string,
  "isPrimary": boolean,
  "isDefault": boolean,
  "treatAsAlias": boolean,
  "smtpMsa": {
    "host": string,
    "port": integer,
    "username": string,
    "password": string,
    "securityMode": string
  },
  "verificationStatus": string
}

【讨论】:

    猜你喜欢
    • 2017-07-27
    • 2016-05-05
    • 1970-01-01
    • 2014-08-02
    • 2021-11-21
    • 1970-01-01
    • 2013-08-15
    • 2023-03-04
    相关资源
    最近更新 更多