我编写了一个脚本,使用每周时间驱动的触发器从谷歌电子表格发送自动电子邮件。我已经对其进行了测试,它似乎只有在我点击“运行”时才有效。时间驱动触发器返回“无效电子邮件:#VALUE!(第 14 行,文件“代码”)”的错误消息。我哪里出错了?任何帮助将不胜感激!
这是我到目前为止所拥有的:
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 20; // Number of rows to process
// Fetch the range of cells A2:c20
var dataRange = sheet.getRange(startRow, 1, numRows, 20)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var message = "Project Owner: " + row[3] + '\n' + "Status: " + row[2]; //3rd column
var subject = "Project Update: " + row[1]; //2nd column
MailApp.sendEmail(emailAddress, subject, message);
}
}