Send List Emails With Time Trigger Google Sheets

How to use :
In Spreadsheet Menu Click Tools and select Script Editor from spinner to go put your script, in Excel "Visual Basic" on developer mode.
In Spreadsheet Menu Click Tools and select Script Editor from spinner to go put your script, in Excel "Visual Basic" on developer mode.
Open Google Apps Script file or create new one : File > New > Script File and name it with whatever you want .
1- Past the script in the bottom of Article and Save the Script.
2- Save the script.
Click that button to save setup the trigger
In that sample i make time trigger to run function sendEmails every hour !
What you need to change :
Line 6: Sheet name is Emails on default you change it according to your sheet name
Line 18: if status is not ready then skip that Email, if you want to avoid that type // in the start of the line.
Line 21: Avoid sending repeating emails each time.
Script :
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'); | |
} | |
} |
Make Copy :
This comment has been removed by a blog administrator.
ReplyDeleteDoes it possible to connect to any other 3rd party SMTP? as gmail have limit number of send per day.
ReplyDelete