I need to receive email if any cell in column H =1 with subject include the data from A,B and h. From the same raw

46 Views Asked by At

I need to receive email if any cell in column H =1 with subject include the data from A,B and h. From the same raw.

I need to receive email if any cell in column H =1 with subject include the data from A,B and h. From the same raw.

1

There are 1 best solutions below

1
Cooper On

All the rows with Column H = 1 in one email

function myfunk00() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("SheetName");
  const sr = 2;//data start row
  const vs = sh.getRange(sr,1,sh.getLastRow() + sr - 1,sh.getLastColumn()).getValues();
  const msg = vs.reduce((acc,r,i) => {
     if(r[7] == 1) {
      acc.push(`Row is ${i + sr} ColumnA is ${r[0]} Column B is ${r[1]} and Column H is ${r[7]}`)
     }
    return acc;
  },[])
  GmailApp.sendEmail('your email','subject',msg.join('\n'))
}

Run this trigger creation function for a message between hours 13 and 14 every day.

function createTrigger() {
  ScriptApp.getProjectTriggers().filter(t => t.getHandlerFunction() == "myFunk00").forEach(t => ScriptApp.deleteTrigger(t));
  ScriptApp.newTrigger("myFunk00").timeBased().atHour(13).create();
}