我有一个脚本,我试图在谷歌文档中的所有工作表上运行,但不知道如何使它工作。它适用于一张纸,但我有许多表格都需要检查相同的格式。谢谢。
这是我试图应用于所有工作表的脚本。
function sendEmail(email_address, email_subject, email_message) {
MailApp.sendEmail(email_address, email_subject, email_message);
}
function timestamp() {
return new Date()
}
var EMAIL_SENT = "EMAIL_SENT";
function test_sendEmail() {
var sheet = SpreadsheetApp.getActiveSheet();
var cell = sheet.setActiveCell('A2');
var criterion_cutoff = 5;
var i = 0;
var startRow = 2;
var addr;
var subj;
var msg;
var timecheck
do {
addr = cell.offset(i,0).getValue();
subj = cell.offset(i,1).getValue();
msg = cell.offset(i,2).getValue();
criterion = cell.offset(i,3).getValue();
timecheck = cell.offset(i,11).getValue();
if (timecheck > 0) {
if(criterion < criterion_cutoff) {
sendEmail(addr,subj,msg);
Browser.msgBox('Sending email to: ' + addr);
}}
i++;
} while( cell.offset(i, 0).getValue().length > 0 )
sheet.getRange(2, 5).setValue(timestamp());
Browser.msgBox('Done!');
}