0
我得到的錯誤,當我運行下面的代碼:錯誤:「無法發送電子郵件:無收件人」
Failed to send email: no recipient
這是正在流失或谷歌電子表格。我假設它將在電子郵件地址欄中查找電子郵件地址,並在它讀取最後一個電子郵件地址後,它將轉到下一個空白單元格,並且看不到任何內容,然後發出錯誤消息。
如果是這樣的話,我怎樣才能讓它停止查找電子郵件地址,當它到列中的最後一個?
的錯誤是在第18行:MailApp.sendEmail(emailAddress, subject, message);
var EMAIL_SENT = "EMAIL_SENT";
function sendEmails2() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var startRow = 2;
var numRows = 1000;
var sheet = ss.getSheetByName ('Administrators')
var dataRange = sheet.getRange(startRow, 1, numRows, sheet.getLastColumn());
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[1];
var message = row[28];
var emailSent = row[29];
if (emailSent != EMAIL_SENT) {
var subject = "Tuition Reimbursement Status";
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 30).setValue(EMAIL_SENT);
var sheet = ss.getSheetByName ('Teachers')
var dataRange = sheet.getRange(startRow, 1, numRows, sheet.getLastColumn());
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[1];
var message = row[28];
var emailSent = row[29];
if (emailSent != EMAIL_SENT) {
var subject = "Tuition Reimbursement Status";
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 30).setValue(EMAIL_SENT);
var sheet = ss.getSheetByName ('Support Staff')
var dataRange = sheet.getRange(startRow, 1, numRows, sheet.getLastColumn());
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[1];
var message = row[28];
var emailSent = row[29];
if (emailSent != EMAIL_SENT) {
var subject = "Tuition Reimbursement Status";
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 30).setValue(EMAIL_SENT);
SpreadsheetApp.flush();
}
}
}
}
}
}
}
這是它的設置,而不是!非常感謝! –
很高興幫助:) – Chris