谷歌脚本的新功能,我无法使下面的代码正常运行。它由onEdit触发,它应循环遍历每一行数据,检查B列是否为" Bypass "或" 拒绝"值,并发送电子邮件到该行的电子邮件地址(列G),除非列A表示它已被发送。然后,在所有这些之后,使用"已发送"更新列A.价值,以便没有人得到双重发送。
这就是我所拥有的,我哪里出错?
function sendEmail() {
// return all data in active spreadsheet
var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues()
for (i in values.length) { //iterate over each row
var data = values[i][1]; // get value of column 2 (aka B) for this row - this is your conditional cell for emailing
var check = values[i][0]; // Previously sent emails
var fname = values[i][2]; // get first name of applicant
var emailAddress = values[i][6]; // get email address from column G
var subject = "Thanks for Applying with Echo Hospitality";
var message = fname + ", <p>After careful review, we are going to move forward with other candidates at this time. Thanks for applying, we appreciate the effort that went into it.<p>Regards,<p>The Echo Hospitality Team";
// if data cell equals Bypass or Declined AND check is not Sent, send email, then update the check column
if (data == "Bypass" || "Declined" && check != "Sent") ;{
MailApp.sendEmail(emailAddress, "hr@echo-staffing.com", subject, message);
check.setValue("Sent");
}
}
}