Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 从谷歌电子表格发送电子邮件”;“只有一次”;_Google Sheets_Email - Fatal编程技术网

Google sheets 从谷歌电子表格发送电子邮件”;“只有一次”;

Google sheets 从谷歌电子表格发送电子邮件”;“只有一次”;,google-sheets,email,Google Sheets,Email,我已经使用IMPORTHTML函数将实时数据导入到Google电子表格中。我的要求是,每当单元格的值超过某个特定数字时,我都需要发送一封电子邮件。我在网上发现了以下内容: { var ss = SpreadsheetApp.getActive(); var sheet = ss.getSheetByName("Profit Ratio"); var valueToCheck = sheet.getRange("D7").getValue(); if(valueToCh

我已经使用IMPORTHTML函数将实时数据导入到Google电子表格中。我的要求是,每当单元格的值超过某个特定数字时,我都需要发送一封电子邮件。我在网上发现了以下内容:

{
   var ss = SpreadsheetApp.getActive();
   var sheet = ss.getSheetByName("Profit Ratio");

   var valueToCheck = sheet.getRange("D7").getValue();

   if(valueToCheck > 3) {
       MailApp.sendEmail("zak*******@gmail.com", "Current Profit Ratio", "Current Profit Ratio is 1:" + valueToCheck+ " !!!");
   }
}

但问题是,如果该值超过3,它会每分钟发送电子邮件,直到低于3为止。我不想那样。我想只发送一次电子邮件,如果它超过3,下一封电子邮件必须是当它再次超过3后,已经下降。另外,我希望获得make
3您可以使用properties服务跟踪当前的标准满足情况是否已经在执行之间得到处理

{
  var ss = SpreadsheetApp.getActive();
  var sheet = ss.getSheetByName("Profit Ratio");
  var valueToCheck = sheet.getRange("D7").getValue();
  var prop = PropertiesService.getDocumentProperties(); // Quick access to properties


  if (valueToCheck > 3                         // Between 3 and 10
        && valueToCheck < 10 
        && !prop.getProperty("processed") {    // Has not been dealt with
    MailApp.sendEmail(
        "zak*******@gmail.com", 
        "Current Profit Ratio", 
        "Current Profit Ratio is 1:" + valueToCheck + " !!!");
    prop.setProperty("processed", true);       // Switch the flag so we don't send any more emails
  } else if (valueToCheck <= 3) {              // You might want to add || value to check >= 10 here?
    prop.setProperty("processed", false);      // Set property to false so that next time the value exceeds 3 we process it again
  }
}
{
var ss=SpreadsheetApp.getActive();
var表=ss.getSheetByName(“利润率”);
var valueToCheck=sheet.getRange(“D7”).getValue();
var prop=PropertiesService.getDocumentProperties();//快速访问属性
如果(值检查>3//介于3和10之间
&&值检查<10
&&!prop.getProperty(“已处理”){//尚未处理
MailApp.sendmail(
“zak******@gmail.com”,
“当期利润率”,
当前利润率为1:“+valueToCheck+”!!!”;
prop.setProperty(“processed”,true);//切换标志,这样我们就不会再发送任何电子邮件了
}如果(这里的valueToCheck=10),则为else?
prop.setProperty(“processed”,false);//将property设置为false,以便下次值超过3时,我们再次处理它
}
}