【发布时间】:2020-06-16 12:29:28
【问题描述】:
我正在尝试使用 Gmail API 文档中的示例,通过表格中的 Google Apps 脚本通过 Gmail API 发送电子邮件,但我收到:
异常:提供的参数数量无效。仅预期 2-4 行(第 240 行,文件“代码”)。
Line 240 是我打电话给Gmail.Users.Messages.send 的时候。这看起来是我可以构建的最基本的电子邮件。有人可以帮我解决我所缺少的吗?
function senDAMail() {
var bdy = "From: steve@gmail.com\n\r, To: steve@gmail.com\n\r, Subject: test\n\r\n\r, You first build the message with headers like From and Subject as you mentioned, but you have to encode the message before sending it. There is no way around that.";
var encodemsg = Utilities.base64EncodeWebSafe(bdy);
Gmail.Users.Messages.send({
auth: this.oAuth2Client,
'userId': 'steve@gmail.com',
'resource': {
'raw': encodemsg
}
});
}
【问题讨论】:
标签: google-apps-script gmail-api