我想要一个函数,让我的脚本在新人提交信息时忽略将合并电子邮件发送到我使用 Google 表单收集的以前的电子邮件。
这是我正在使用的脚本:
function sendMail() {
const emailTemp = HtmlService.createTemplateFromFile("email");
const sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("form1");
const startRow = 2
const data = sh.getRange(startRow, 2, sh.getLastRow() - 1, sh.getLastColumn() - 1).getValues();
data.forEach((row, i) => {
emailTemp.fullname = row[1];
emailTemp.phone = row[2];
let htmlMessage = emailTemp.evaluate().getContent();
let emailSent = row[6];
if (emailSent != "EMAIL_SENT") {
GmailApp.sendEmail(row[0],"Thank you!","Your email doesn't support HTML.",{ name: "Email App", htmlBody: htmlMessage });
sh.getRange(startRow + i, 6).setValue("EMAIL_SENT");
}
});
}
我想忽略 F 列中具有 EMAIL_SENT 值 的所有行:
谢谢。
最佳答案
这就是这一行的作用 if (emailSent != "EMAIL_SENT") {
这个 let emailSent = row[6];
应该是这个let emailSent = row[4];
根据您原来的问题,您的行从第 2 列开始。
关于javascript - 如何在收到新的 Google 表单提交后忽略向具有值的行发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68548599/