我是一位老师,也是AppScript的新手。我创建了一个电子表格,通过谷歌电子表格自动通过Gmail发送反馈给学生。它确实有效,电子邮件从电子表格发送,但我收到以下错误'无效的电子邮件<>'在电子表格上。
如果有人能帮助它,我们将非常感激。
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menu = [{
name: "Send Email",
functionName: "uiSendEmail"
}];
ss.addMenu("Send Email", menu);
}
function uiSendEmail() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var range = sheet.getDataRange();
range = range.offset(1, 0, range.getNumRows()-1);
range.getValues().forEach( function( recipient, index, data ){
var msgHtml = "Hi " + recipient[0] + "," + "<p>" + "Atttitude to Learning Grade is: " + "<b><u>" + recipient[5] + "</b></u>" + "<p>" + "Feedback: " + recipient[6] + "<p>" + "Improvements to be made: " + recipient[7] + "<p>" + "Overall Grade: " + recipient[8];
var subject = recipient[3] + " - Teacher Feedback";
var msgPlain = msgHtml.replace(/(<([^>]+)>)/ig, ""); // clear html tags for plain mail
GmailApp.sendEmail(recipient[0] + " " + recipient[1] + "<" + recipient[2] + ">", subject, msgPlain, { htmlBody: msgHtml });
});
}
答案 0 :(得分:0)
这是很久以前的事了,所以我假设你想出了什么......(我偶然发现了这个试图解决相关问题)。
从上面的代码和错误中,我可以看到收件人数组中没有数据。