如果单元格包含特定值,请在编辑时发送电子邮件 [英] Send an email on edit if a cell contains specfic value
问题描述
如果有人在A1中输入completed,我希望它发送一封电子邮件到特定的电子邮件地址。
最初,我设置了一个完成按钮,但它在手机上无法使用。所以我现在只需要它给我发一封电子邮件,当有人输入完成一词时。
在这个回答中描述了用于发送电子邮件的可安装编辑触发器功能。您只需调整该功能即可关注您感兴趣的单元格或范围,并将其构建并安装发送你想要的电子邮件。
$ b
function installableOnEdit(e){
if(! e)抛出新的错误(需要事件参数。); //请参阅https://stackoverflow.com/a/16089067
var changedCell = e.range;
var row = changedCell.getRow();
var col = changedCell.getColumn();
//检查变化是否在A1
if(row === 1&&& col === 1
&& e.value.toString( ).match(/ completed / i))//不区分大小写的检查
var recipient = Session.getActiveUser()。getEmail(); //发送给所有者
MailApp.sendEmail(收件人,任务已完成,Cell A1说:+ e.value);
}
}
I thought this would be simple, but I can't figure it out.
If someone types "completed" into A1, I want it to send an email to a specific email address.
Initially I set up a "completed" button, but it doesn't work on mobile. So I now just need it to send me an email when someone types in the word "completed".
The operation of an installable edit trigger function for sending an email is described in this answer. You simply need to tweak that function to focus on the cell or range you're interested in, and have it build & send the email you want.
function installableOnEdit( e ) {
if (!e) throw new Error( "Need event parameter." ); // see https://stackoverflow.com/a/16089067
var changedCell = e.range;
var row = changedCell.getRow();
var col = changedCell.getColumn();
// check if change was in A1
if (row===1 && col===1
&& e.value.toString().match(/completed/i)) // case-insensitive check
var recipient = Session.getActiveUser().getEmail(); // send to owner
MailApp.sendEmail( recipient, "Task Completed", "Cell A1 says: "+e.value );
}
}
这篇关于如果单元格包含特定值,请在编辑时发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!