尝试使用 GmailApp.sendEmail - 获取缺少的访问令牌以进行授权
Trying to use GmailApp.sendEmail - Getting Missing access token for authorization
我正在尝试在我目前正在开发的插件中使用 GmailApp.sendEmail()
,即使我已经为它提供了必要的范围,它仍然无法发送消息:
"Access denied: : Missing access token for authorization. Request:
MailboxService.SendMessage."
在项目清单文件中添加了所有需要的范围:
"oauthScopes" : [
"https://www.googleapis.com/auth/gmail.addons.current.action.compose",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/script.locale",
"https://mail.google.com/",
"https://www.googleapis.com/auth/gmail.modify",
"https://www.googleapis.com/auth/gmail.compose",
"https://www.googleapis.com/auth/gmail.send",
"https://www.googleapis.com/auth/gmail.addons.current.action.compose",
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata"
]
.gs 文件
function validateRecipients(e) {
var toEmails = e.draftMetadata.toRecipients, ccEmails = e.draftMetadata.ccRecipients, bccEmails = e.draftMetadata.bccRecipients, domains = [], uniqueDomains = [];
var allEmails = toEmails.concat(ccEmails, bccEmails);
for (var i = 0; i < allEmails.length; i++) {
domains[i] = allEmails[i].split("@").pop().split(".")[0];
}
uniqueDomains = domains.filter(listUnique);
if(uniqueDomains.length <= 2 && uniqueDomains.indexOf("verasafe") != -1) {
Logger.log("This Message is Good to Go");
}
else if(uniqueDomains.length == 0) {
Logger.log("This Message has no recipients");
}
else {
Logger.log("Please Validate Receipients of this Message and Try again");
GmailApp.sendEmail("sherifkd@gmail.com", "Disclosure Alert", "This message might be sent to the following multiple external domains:");
}
}
添加那个:"https://www.googleapis.com/auth/script.send_mail",
我认为这是你的错误来源。
我正在尝试在我目前正在开发的插件中使用 GmailApp.sendEmail()
,即使我已经为它提供了必要的范围,它仍然无法发送消息:
"Access denied: : Missing access token for authorization. Request: MailboxService.SendMessage."
在项目清单文件中添加了所有需要的范围:
"oauthScopes" : [
"https://www.googleapis.com/auth/gmail.addons.current.action.compose",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/script.locale",
"https://mail.google.com/",
"https://www.googleapis.com/auth/gmail.modify",
"https://www.googleapis.com/auth/gmail.compose",
"https://www.googleapis.com/auth/gmail.send",
"https://www.googleapis.com/auth/gmail.addons.current.action.compose",
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata"
]
.gs 文件
function validateRecipients(e) {
var toEmails = e.draftMetadata.toRecipients, ccEmails = e.draftMetadata.ccRecipients, bccEmails = e.draftMetadata.bccRecipients, domains = [], uniqueDomains = [];
var allEmails = toEmails.concat(ccEmails, bccEmails);
for (var i = 0; i < allEmails.length; i++) {
domains[i] = allEmails[i].split("@").pop().split(".")[0];
}
uniqueDomains = domains.filter(listUnique);
if(uniqueDomains.length <= 2 && uniqueDomains.indexOf("verasafe") != -1) {
Logger.log("This Message is Good to Go");
}
else if(uniqueDomains.length == 0) {
Logger.log("This Message has no recipients");
}
else {
Logger.log("Please Validate Receipients of this Message and Try again");
GmailApp.sendEmail("sherifkd@gmail.com", "Disclosure Alert", "This message might be sent to the following multiple external domains:");
}
}
添加那个:"https://www.googleapis.com/auth/script.send_mail",
我认为这是你的错误来源。