Last active
July 21, 2022 15:17
-
-
Save chemiadel/f1314bf8403eda071ca10c584947d1e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://gist.github.com/chemiadel/f1314bf8403eda071ca10c584947d1e7 | |
//Sheet Name | |
SHEET_NAME="Emails" | |
function sendEmails() { | |
//Assign Spreadsheet, Sheet to object variables | |
var ss=SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet=ss.getSheetByName(SHEET_NAME); | |
//Get data into 2D Array | |
var values=sheet.getRange('A2:E'+sheet.getLastRow()).getValues(); | |
for(var i in values){ | |
//Verify if email is Ready | |
if(values[i][3]!='Ready') continue; | |
//Verify if Email sent before to avoid resending it again | |
if(values[i][4]!='Sent') continue; | |
//Send Email (Email Adress, Title, Body) | |
GmailApp.sendEmail(values[i][0], values[i][1], values[i][2]); | |
//Mark sent to each email has been sent | |
sheet.getRange(2+parseInt(i), 5).setValue('Sent'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment