0
我一直在試圖編寫一個Google表單的函數,它會發送一封電子郵件給表單指定的特定教師。問題是我不斷收到一個簡單的if語句的錯誤。錯誤說:「缺少;在聲明之前(第29行,文件」代碼「)」。該代碼基於此Google Apps教程:https://developers.google.com/apps-script/articles/mail_merge#section-5-full-code。這是我現在所擁有的:谷歌表格如果命令錯誤
function sendEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var dataSheet = ss.getSheets()[0];
var dataRange = dataSheet.getRange(2, 1, dataSheet.getMaxRows() - 1, 4);
var templateSheet = ss.getSheets()[1];
var emailTemplate = templateSheet.getRange("A1").getValue();
// Create one JavaScript object per row of data.
var objects = getRowsData(dataSheet, dataRange);
// For every row object, create a personalized email from a template and send
// it to the appropriate person.
for (var i = 0; i < objects.length; ++i) {
// Get a row object
var rowData = objects[i];
// Generate a personalized email.
// Given a template string, replace markers (for instance ${"First Name"}) with
// the corresponding value in a row object (for instance rowData.firstName).
var emailText = fillInTemplateFromObject(emailTemplate, rowData);
var emailSubject = "Lab Visit Report";
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
for (var i = 0; i < data.length; i++) {
var teacher = data[i][10];
If (teacher == "Jake Nabasny") {MailApp.sendEmail("[email protected]", emailSubject, emailText);}
else if (teacher == "Dan S") {MailApp.sendEmail("[email protected]", emailSubject, emailText);}
}
}
我已經確定變量(如teacher和emailText)包含數據。據我所知,這個問題完全在於if語句。任何人都可以給我一個這裏發生了什麼問題的想法嗎?
謝謝!多麼愚蠢的小錯誤:/ –