每次在 Google 表格上更新一行时,我都会尝试触发电子邮件。但是,当添加 1 行时,会触发太多电子邮件。我使用的代码如下。
`
function valueCheck(e) {
var ss= SpreadsheetApp.getActive();
var sheet1= ss.getSheetByName("Applications");
var lastRow = sheet1.getLastRow();
var companyName = 2;
var applicationLink=3;
var com = sheet1.getRange(lastRow, companyName).getValue();
var link1= sheet1.getRange(lastRow, applicationLink).getValue();
if (link1)
{
MailApp.sendEmail("r***@gmail.com","Apply to "+com,"link to apply:"+link1);
}
}
答案 0 :(得分:0)
尝试这样的事情:
function onMyChange(e) {
const sh=e.source.getActiveSheet();
//e.source.toast('Entry');//for debugging
//sh.getRange('A1').setValue(JSON.stringify(e));//You use this to learn more about the event object
if(sh.getName()=='Sheet1' && e.changeType=="EDIT") {//I assume you're using EDIT changeType
//e.source.toast('Sheet1')//for debugging
//do your stuff in here
}
}
我不知道你想使用什么 changeType。