此代码中没有错误,但代码不执行任何操作。
我正在制作一个代码,用于在阅读当天的日期并与特定列中的日期相关时,会发送自动发送电子邮件。
function sendEmail() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
SpreadsheetApp.setActiveSheet(ss.getSheetByName('Orçamento'))
var sheet = ss.getActiveSheet();
var startRow = 2; // First row of data to process
var lastRow = sheet.getLastRow(); // Number of rows to process
var numColumn = sheet.getLastColumn();
// grab column 5 (the 'days left' column)
var data = sheet.getRange(2,6,lastRow-startRow+1,1 );
var numRows = data.getNumRows();
var date_values = data.getValues();
// Now, grab the reminder name column
data = sheet.getRange(2, 2, lastRow-startRow+1, 1);
var reminder_info_values = data.getValues();
//Logger.log(data)
for (i in data) {
var column = data[i];
var date = new Date();
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
//Logger.log(date);
var sheetDate = new Date(column[6]);
//Logger.log(sheetDate);
var Sdate = Utilities.formatDate(date,'GMT-0300','yyyy:MM:dd')
var SsheetDate = Utilities.formatDate(sheetDate,'GMT-0300', 'yyyy:MM:dd')
Logger.log(Sdate+' =? '+SsheetDate)
if (Sdate == SsheetDate){
var obra = column[1];
var descricao = column[2];
var inicio = column[6];
var fim = column[7];
var compra = column[8]; // Contact Method
var subject = "Lembrete de início de Serviço: " +obra;
var message = "O serviço: " + descricao + "tem previsão de data de início em " + inicio + "e previsão de término em : " + fim + "a previsão de compra do material é em: " + compra + ". Fique atento para não atrasar este serviço ";
MailApp.sendEmail({
to: "bruno@formula.eng.br",
subject: subject,
body: message,
});
}
}
}