0

如果 Google 表格中的列 =X,我正在尝试收到一封电子邮件来提醒我。

我尝试使用通知系统,使用 EQ 运算符在单元格等于 X 时打开,这会更改单元格并且通知系统应该立即发送电子邮件。它不是那样工作的,电子邮件永远不会触发。

我想我需要一个脚本,如果一个单元格 =X 会触发一封电子邮件,这会很好,因为我可以自定义电子邮件,所以它更有意义。(即“您的活动正在举行的会议室已满员,您应该将其从预订表中删除”)

我是 Google Scripts 的新手,如果 cell =X 脚本,我可以使用一些帮助来创建电子邮件触发器。

谢谢,

戴夫

4

2 回答 2

0

您需要添加一个脚本来运行 onEdit。

function onEdit() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("NameOfYourSheet");
  var currentValue = sheet.getRange("A5").getValue();
  if (currentValue == (whateverValueYoureLookingFor)) {
    MailApp.sendEmail("youremail@domain.com", "ALERT: The cell in the sheet is equal to X!", "The message body that you want to send.");
  }
}
于 2013-02-07T17:49:59.597 回答
0
function testSchemas() {
  var htmlout = HtmlService.createTemplateFromFile('data').evaluate().getContent();

 var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('All Exams Tracker');
var range = sheet.getDataRange();
  var values = range.getValues();
  var last_row = sheet.getLastRow();
  var today = new Date()


  for (var i =3 ;i < last_row;i++) {
   var temp = values[i][4];
    var e_date = new Date(temp);
    if ((( e_date - today)/(1000*60*60*24)) < 10 && e_date > today){
      var cond = "done" }
    break; }
Logger.log(cond);  

  if (cond == "done"){


 MailAppv.sendEmail({
    to: '*************************************************************',
     subject: 'Exam Coming Next Week',
    htmlBody: htmlout,
  });

  }}

这将在触发时生成 html 文件数据(如下所示)。

<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;

}
</style>
</head>
<table style = "border: 1px solid black; border-style: collapse;">
<?   var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('All Exams Tracker');
var range = sheet.getDataRange();
  var values = range.getValues();
  var last_row = sheet.getLastRow();

  var today = new Date();?>

  <tr style="border: 1px solid black; padding: 10px;">

    <th style="border: 1px solid black; padding: 10px;">Exam Name</th>
    <th style="border: 1px solid black; padding: 10px;">Exam Date</th>
    <th style="border: 1px solid black; padding: 10px;">Priority</th>
    <th style="border: 1px solid black; padding: 10px;">College Predictor Status</th>
     <th style="border: 1px solid black; padding: 10px;">Rank Predictor Status</th>

</tr>

  <? for (var i =3 ;i < last_row;i++) {
   var temp = values[i][4];
    var e_date = new Date(temp);
    if ((( e_date - today)/(1000*60*60*24)) < 10 && e_date > today) {


   if (values[i][12] != ""){
  var col_status = "Live"}
  else
  if (values[i][11] != ""){
  col_status = "Uploaded and Tested"}
  else
  if (values[i][10] != ""){
  col_status = "Data Processed"}
  else
  if (values[i][9] != ""){
  col_status = "Template Ready"}

  else
  col_status = "Not initiated yet"

   if (values[i][19] != ""){
   var rank_status = "Live"}
  else
  if (values[i][18] != ""){
  rank_status = "Uploaded and Tested"}
  else
  if (values[i][17] != ""){
  rank_status = "Data Processed"}
  else
  rank_status = "Not Initiated yet"   


  ?>
<tr>

    <td style="border: 1px solid black; padding: 10px;"><?= values[i][2]?></td>
    <td style="border: 1px solid black; padding: 10px;"><?= values[i][4]?></td>
    <td style="border: 1px solid black; padding: 10px;"><?= values[i][8]?></td>
    <td style="border: 1px solid black; padding: 10px;"><?= col_status?></td>
    <td style="border: 1px solid black; padding: 10px;"><?= rank_status?></td>

</tr>
<? } }?>
</table>
<br><br>
<p><a href="https://docs.google.com/spreadsheets/d/1fzbRCvnNfuVTCEuRnncJxb1VW7f-tkSEywntzaTugZQ/edit#gid=0">Click Here For More Details</a></p>
</html>
于 2017-05-18T20:11:59.023 回答