2017-08-28 155 views
1

我是GAS和Gmail API的新手,并尝试使用带有Gmail API的Google Apps脚本从Google电子表格中触发电子邮件。Google Apps脚本 - 使用Gmail签名发送电子邮件

我的问题是,是否可以在电子邮件中包含用户的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向我展示测试电子邮件,我将非常感激。电子邮件可以使用纯文本。

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

+0

设置一个什么你现在使用的代码来触发电子邮件?在你的工作表中,你可以使用'GmailApp'类而不是'MailApp'。 [更多关于在电子表格中使用Gmail API](https://developers.google.com/apps-script/reference/gmail/gmail-app)。 – Brian

+0

感谢您回复Brian。 MailApp.sendEmail(to,subject,'',{htmlBody:body,cc:''+ cc,bcc:''+ bcc});但有了这个我可以包括我的Gmail签名吗?如果这是可能的,那么我的问题就解决了。 – Prahlad

+0

明白了。因此,不,您无法访问标准GmailApp类中的签名。您需要在下面的答案中使用高级Google服务。 – Brian

回答

1

docs看来,这确实是可能的。

进行更新,你需要发送一个PUT请求到这个资源:

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 
} 
相关问题