1

我正在尝试向技术人员设置一封简单的提醒电子邮件,以提醒常规服务何时到期。我有一个二维数组和有效的代码,但它只发送 1 封电子邮件,这是最低行。我对此有点陌生,但我希望它遍历每一行并为每次过期发送提醒。任何帮助表示赞赏。

这就是我现在所拥有的:

    function Email_Reminder() 
    {;

    var sheet = SpreadsheetApp.getActiveSheet();

    statusArray = sheet.getDataRange().getValues();

    status = "overdue";
    for (i=3;i < statusArray.length;i++){
    if (status == statusArray[i][6]) {
    var customer = statusArray[i][0];
    }
    }
    var email   = "djens12@gmail.com"
    var subject = "Reminder";
    var body    = "This is a reminder that the service is overdue for " +customer+ "";

                      MailApp.sendEmail(email,subject,body,{NoReply : true});
                      }

谢谢

4

1 回答 1

0

只需移动你的循环MailApp.sendEmail()for

function Email_Reminder() 
    {;

    var sheet = SpreadsheetApp.getActiveSheet();

    statusArray = sheet.getDataRange().getValues();

    status = "overdue";
    var email   = "djens12@gmail.com"
    var subject = "Reminder";

    for (i=3;i < statusArray.length;i++){
      if (status == statusArray[i][6]) {
        var customer = statusArray[i][0];
        var body    = "This is a reminder that the service is overdue for " +customer+ "";
        MailApp.sendEmail(email,subject,body,{NoReply : true});
      }
    }
  }
于 2013-08-29T08:28:22.980 回答