Advertisement
RemcoE33

Daily emails

Jun 21st, 2021
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dailyEmail(){
  2.   const ss = SpreadsheetApp.getActiveSpreadsheet()
  3.   const sheet = ss.getSheetByName('Data')
  4.   const values = sheet.getRange("A2:E2").getValues().flat()
  5.   const date = Utilities.formatDate(new Date(values[0]), Session.getScriptTimeZone(), "dd-MM-yyyy")
  6.   const body =
  7.     `Hi, \n
  8.     Here are the figures for yesterday, ${date}: \n
  9.     Value 1 = ${values[1]}
  10.     Value 2 = ${values[2]}
  11.     Value 3 = ${values[3]}
  12.     Value 4 = ${values[4]}
  13.  
  14.     Regards,
  15.     RemcoE33`
  16.  
  17.   GmailApp.sendEmail('email@gmail.com', 'Yesterdays values', body)
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement