Is there a way to have the sending email script throttle (pace) the emails?

108 views
Skip to first unread message

Bruno Vincent

unread,
Dec 18, 2021, 12:30:48 PM12/18/21
to Google Apps Script Community
I want to send bulk email, but I don't want them to go out in one shot.

I'm not a coder, but I suspect the script loops through spreadsheet rows iterations.

Is there a way to modify the script so it sends emails at fixed X minutes or seconds intervals ? Or even better at random intervals , say between 1-5 minutes per individual message? 

The script I'm talking about is over here:

https://developers.google.com/apps-script/samples/automations/mail-merge

Actually script is over here:

Clark Lind

unread,
Dec 20, 2021, 7:06:38 AM12/20/21
to Google Apps Script Community
I think you should be able to use the Utilities.sleep() function to pause the script. So where it is doing the looping and sending, just inject the sleep() somewhere in the loop, maybe even at the beginning:

// loop through all the rows of data
  obj.forEach(function(row, rowIdx){
Utilities.sleep(60000); //pause for 1 minute; maximum pause is 5 minutes (300000 mil-sec)
    // only send emails is email_sent cell is blank and not hidden by filter
    if (row[EMAIL_SENT_COL] == ''){
Reply all
Reply to author
Forward
0 new messages