当单元格具有特定值时触发电子邮件 [英] Trigger an email when a cell has certain values
问题描述
function onEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet()
var cell = ss.getActiveCell()。activate();
Logger.log(cell.getA1Notation()); (cell.getValue()。match(ass)){
MailApp.sendEmail(example@example.com,可能不合适tweet的通知,cell;
if }
$ b $`b
$ b $ p $这是一个不恰当的单词的代码,显然,因为我只是在添加100个不恰当的单词之前试图获得编码的基础知识,麻烦的是,如果表单同时收到三条推文,它只会检查最后一条,所以这是我现在的主要麻烦所在。
任何指导或帮助在这里非常感谢!
方案
我同意上面的Camerons评论,如果你能描述什么不是专门为你工作的,那会让我们知道你需要什么帮助。
现在,您的代码为我运行,当我编辑单元格以包含单词'ass'时,它会通过电子邮件发送给我。
但是, catch是目前在邮件正文中的哟这里有一个稍微更新的版本,可以在电子邮件中提供更有用的表示法:
$ b $ pre $
function onEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet(); //获取电子表格
var sheet = ss.getActiveSheet()//获取活动工作表
var cell = ss.getActiveCell()。activate(); //获取活动单元格。
var badCell = cell.getA1Notation(); //获取单元格A1记法。
var badCellContent = cell.getValue(); //获取该单元格的值。
if(badCellContent.match(ass)){
MailApp.sendEmail(example@example.com,通知可能不适当的推文,The cell:+ badCell +包含单词:+ badCellContent +。);
}
}
I am a basketball coach & I am creating a dashboard to monitor my players' social media. I'm using IFTTT.com to pull in all of my players' tweets in real-time to a spreadsheet. I'm trying to write a code that if one of my players uses an inappropriate word, it'll trigger an email to me of that cell. I feel like I'm on the right track, but some guidance on my code is greatly appreciated.
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet()
var cell = ss.getActiveCell().activate();
Logger.log( cell.getA1Notation() );
if (cell.getValue().match("ass")) {
MailApp.sendEmail("example@example.com", "Notice of possible inappropriate tweet", cell;}
}`
This is the code for just one inappropriate word, obviously, as I'm just trying to get the basics of the coding down before I add 100 inappropriate words. The trouble is that if the sheet pulls in three tweets at the same time, it's only going to check on the last one, so that's where my main troubles lie right now.
Any guidance or help here is greatly appreciated!
I agree with Camerons comments above, if you can describe what's not working for you specifically, that would give us an idea of what you need help with.
As it stands, your code runs for me, and it will email me when I edit a cell to contain the word 'ass'.
However, one catch is that currently in the body of the email you have the variable 'cell' which will only return the word 'range'.
Here's a slightly updated version that provides more helpful notation in the email:
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();//Get the spreadsheet
var sheet = ss.getActiveSheet()//Get the active sheet
var cell = ss.getActiveCell().activate();//Get the active cell.
var badCell = cell.getA1Notation();//Get the cells A1 notation.
var badCellContent = cell.getValue();//Get the value of that cell.
if (badCellContent.match("ass")){
MailApp.sendEmail("example@example.com", "Notice of possible inappropriate tweet", "The cell: " + badCell + " contains the word: " + badCellContent + ".");
}
}
这篇关于当单元格具有特定值时触发电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!