很抱歉,有很多代码,但是我快要死了。我正在尝试创建触发器以将电子邮件发送到特定地址,然后将列I标记为“ Email_Sent”。然后,该脚本应在每次提交新表单并检查数据时触发,并检查I列中的“ Email_Sent”,如果存在,则不要触发另一封电子邮件。到目前为止,当我手动运行它时,它仍然有效,但仅适用于第一行数据。谁能帮助我找出导致卡住的原因?这是我到目前为止所拥有的-
var EMAIL_SENT = 'EMAIL_SENT';
function sendFormByEmail(e) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1");
var startRow = 2; // First row of data to process
var numRows = 9; // Number of rows to process
var dataRange = sheet.getRange(startRow, 9);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = 'alias@email.com';
var message = "Hey! You have new feedback to review. Check out the tracker to review and acknowledge-"; // Second column
var emailSent = 9; // In this column, script will write “E-mail Sent.” Future e-mail will not be sent if “E-mail sent” exists
var emailSent2 = row[emailSent];
if (emailSent2 != EMAIL_SENT) { // Prevents sending duplicates
var subject = 'New Feedback!';
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, emailSent).setValue(EMAIL_SENT);
SpreadsheetApp.flush();
}
}
}