在Google SpreadSheets中更改单元格后发送电子邮件

时间:2017-03-16 14:50:02

标签: google-apps-script

我需要帮助我创建的脚本。我需要随时向自己或经理发送电子邮件" F"更改为"是"。我认为我的代码没问题,但我不认为我的触发器允许我完成该功能。任何帮助将不胜感激。

function sendNotification() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var cell = ss.getActiveCell().getA1Notation();
  var row = sheet.getActiveRange().getRow();
  var cellvalue = ss.getActiveCell().getValue().toString();

  var sendto = 'd.hammond@permasteelisagroup.com';
   if(cell.indexOf('F')!=-1){ 
      sendto = sheet.getRange('F'+ sheet.getActiveCell().getRowIndex()).getValue()
      }   
  var designer = '';
     designer = sheet.getRange('A' + sheet.getActiveCell().getRowIndex()).getValue()
  var assignment = '';
      assignment = sheet.getRange('B' + sheet.getActiveCell().getRowIndex()).getValue()
  var comment = '';
      comment = sheet.getRange('I' + sheet.getActiveCell().getRowIndex()).getValue() 
  var checked_by = '';
      checked_by = sheet.getRange('G' + sheet.getActiveCell().getRowIndex()).getValue()

  var mysubject = ss.getName() + ':' + 'Review Drawing: \n';
  var mybody = 'Please review: ' + assignment + ' \n' + 'Drawn by: ' + designer + '\n' + 'Please review any comments' + comment + ' \n' + 'Due by: ' + checked_by;


  MailApp.sendEmail({
    to:sendto, 
    subject:mysubject,
    body:mybody});
};

*

0 个答案:

没有答案