Apps脚本来获取用户签名 [英] Apps Script to get the users signature

查看:64
本文介绍了Apps脚本来获取用户签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个应用程序脚本,它将使用联系人详细信息创建一个新的电子邮件草稿,从而进行简单的邮件合并。它按预期工作,但我想在模板中使用当前用户的签名。

I have created an apps script that will do a simple mail merge using contact details to create a new email draft. It works as expected, but I would like to use the current user's signature in the template.

有关此文档的日期和不完整。我从我发现的内容中创建了下面的代码,但由于找不到官方文档,所以不得不猜测它需要什么。

Documentation on this is dated and incomplete. I created the code below from what I have found, but have had to make a total guess as to what it needs because I can't find the official documentation.

var params;
params = {method:"post",
          contentType: "application/json",
          headers: {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
          muteHttpExceptions:true
        };

var resp = UrlFetchApp.fetch("https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/me/signature", params);
var rCode = resp.getResponseCode();
var rText = resp.getContentText();

这是回应:

This is the response:

rCode = 400
rText = Invalid request URI

是正确的请求URI?有没有新的API?

What is the correct request URI? Is there a new API for this?

推荐答案

Gmail签名现在可以通过gmail API访问。我在下面添加了一个班轮,以获得当前用户的签名。我使用了 list 而不是 get ,因为用户默认情况下可能会以其他用户的身份发送电子邮件,然后他们会登录帐户。所以我 list 所有帐户,并过滤出默认的帐户。

Gmail signatures are now accessible from the gmail API. I added a one liner below to get the signature of the current user. I used list instead of get because a user may send email as a different user by default then their logged in account. So I list all accounts and filter out the default one.


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



var signature = Gmail.Users.Settings.SendAs.list("me").sendAs.filter(function(account){if(account.isDefault){return true}})[0].signature;

这篇关于Apps脚本来获取用户签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆