简体   繁体   中英

Send mail based on Google Sheet Cell value

I am trying to send auto generated mail based on text value of Google sheet. In My Sheet column, F is the row with the status " Approved' Or "Rejected"

If Status is " Approved' mail should generate

I have created the code, however, i think need small modifications

  function myNotification() { var ss = SpreadsheetApp.getActiveSpreadsheet() var ss_sheet = ss.getSheetByName('Form Responses 1') var ss_sheet_datarange = ss.getDataRange().getValues(); var ss_sheet_lastrow = ss_sheet.getLastRow() for (var i = 5; i < ss_sheet_lastrow; i++) var approvalstatus = ss_sheet_datarange[5][i] // column F is the row with the status in var approval_status = 5; if (approval_status == 'Approved') { var email = Session.getUser().getEmail(); MailApp.sendEmail(email, "Test", "Test"); } 

Change
if (approval_status == 'Approved') {

For if (approvalstatus == 'Approved') {

You have two variables very similar, but in your code, approval_status will ALWAYS be 5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM