I'm trying to schedule an Apps Script function. I need the email to trigger Mon-Sat every 2 hours starting at 11am-9pm.
I've written the following code to create triggers for each day:
function createTriggers() {
var days = [ScriptApp.WeekDay.MONDAY,
ScriptApp.WeekDay.TUESDAY,
ScriptApp.WeekDay.WEDNESDAY,
ScriptApp.WeekDay.THURSDAY,
ScriptApp.WeekDay.FRIDAY,
ScriptApp.WeekDay.SATURDAY];
for (var i=0; i<days.length; i++) {
ScriptApp.newTrigger('emailDashboard')
.timeBased().onWeekDay(days[i])
.everyWeeks(1).everyHours(2).create();
}
}
When I run what I have above, I get the following error:
"The recurrence interval on the clock trigger has already been set. (line 79, file "Code")"
I cant find anything about that response, and it doesn't actually create the trigger. I assume what I have above would get me the email Mon-Sat, every 2 hours. I'm not sure how to go about starting at 11am central and ending at 9pm central.