google-apps-script - 谷歌脚本触发了太多电子邮件
问题描述
每次在谷歌工作表上更新一行时,我都会尝试触发一封电子邮件。但是,添加 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);
}
}
解决方案
尝试这样的事情:
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 。
推荐阅读
- facebook - 非托管游戏的游戏邀请
- ios - 使用 IQKeyboardManagerSwift 不显示下一个/上一个按钮
- python - 修复将整数列表转换为 NumPy 矩阵的方法
- php - PHP OScommerce 尝试选择 mysql db 获取参数错误
- tensorflow - TensorFlow:在测试时丢弃卷积梯度/参数
- python - 如何在 Python 中使用 OpenCV 以特定顺序显示图像?
- python - 如何将文件保存数组中的字符串转换为python中的数组对象?
- image - 如何读取和写入 uint 格式的图像?
- python - 修改列表以复制另一个列表而不复制原始列表
- sql-server - 在 SQL Server 中使用 case when 和 substring 时防止删除前导零