我正在尝试运行上面的脚本。我有一个谷歌电子表格,我包括一个菜单。我希望能够在单击菜单,电子邮件列表下的任何选项时准备好发送模板。我是新手,我试图运行下面的脚本,但我收到一个错误。我附上了剧本。谁能帮我理解这里的问题是什么?
function onOpen() {
var subMenus = [{name:"Title 1", functionName: "t1"},
{name:"Title2", functionName: "t2"},
SpreadsheetApp.getActiveSpreadsheet().addMenu("Email List", subMenus);
}
function t1() {
var address = "test@test.com"
var body = "Dear Employee," +
"Today You didnt request your logon time" +
"Sincerely,"
"Your Name"
"Thank you";
MailApp.sendEmail(address,body);
}
答案 0 :(得分:1)
您的代码中存在许多基本语法错误,脚本编辑器甚至不允许保存它们。但我在其中看到的唯一“逻辑”问题是,您忘记了subject
电话上的MailApp.sendEmail
参数。这是修复代码:
function onOpen() {
var subMenus = [{name:"Title 1", functionName: "t1"},
{name:"Title2", functionName: "t2"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu("Email List", subMenus);
}
function t1() {
var address = "test@test.com";
var body = "Dear Employee," +
"Today You didnt request your logon time"+
"Sincerely,"+
"Your Name"+
"Thank you";
var subject = "subject example";
MailApp.sendEmail(address, subject, body)
}