javascript - 收到新的 Google 表单提交后,如何忽略向具有价值的行发送电子邮件?
问题描述
当有人新提交他的信息时,我想要使我的脚本忽略发送合并电子邮件到我使用 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");
}
});
}
谢谢你。
解决方案
这就是这条线的用途 if (emailSent != "EMAIL_SENT") {
let emailSent = row[6];
应该是这个let emailSent = row[4];
根据您的原始问题,您的行从第 2 列开始。
推荐阅读
- php - 计算特定月份和日期给定 DoB 的年龄
- javascript - 仅在“a”元素上的 html 基本元素
- javascript - 如何
从字符串中全局删除“” - javascript - 将机器人与 Azure 语音服务问题集成
- vba - MS-Word 宏 - 替换 - 下班后确认
- amazon-web-services - 为什么我的缩减策略没有覆盖 Auto Scaling 组所需容量
- python - 我不能让窗户按我的意愿行事
- transition - 自动播放时 JSSOR 转换不起作用
- c# - 如何检查列表视图是否包含c# UWP中的任何内容
- design-patterns - 轮询数据仓库设计