Send email to specific addresses based on cell value change in google sheets

白昼怎懂夜的黑 提交于 2020-07-23 07:41:28

问题


Whenever a cell in column G of my spreadsheet is changed to "paid", I would like emails to be sent to the addresses contained in columns J and K on the same row, with the email subject being column A of that row, and the email message "paid"

I have seen several similar questions, but am a novice user and have trouble modifying them to suit my project needs. Any help appreciated!


回答1:


function onEdit(e) {
  var sh=e.range.getSheet();
  if(e.range.columnStart==7 && e.value.toLowerCase()=='paid' && sh.getName()=='Sheet Name') {
    var vA=sh.getRange(e.range.rowStart,1,1,sh.getLastColumn()).getValues()[0];
    var recipient=Utilities.formatString('%s,%s', vA[9],vA[10]);
    var subject=vA[0];
    GmailApp.sendEmail(recipient, subject, 'Paid');
  }
}

Note: You cannot run this function from the script editor. You will also have to update the SheetName in line 3

Event Objects

Simple Triggers



来源:https://stackoverflow.com/questions/58275064/send-email-to-specific-addresses-based-on-cell-value-change-in-google-sheets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!