当单元格具有特定值时触发电子邮件 [英] Trigger an email when a cell has certain values

查看:427
本文介绍了当单元格具有特定值时触发电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名篮球教练&我正在创建一个仪表板来监视我的玩家的社交媒体。我使用IFTTT.com将我所有玩家的推文实时导入电子表格。我试图编写一个代码,如果我的一个玩家使用了不恰当的单词,它会触发一封电子邮件给我。我觉得我在正确的轨道上,但我的代码的一些指导,不胜感激。

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆