The below script was correctly sending one weekly email to each person who met the conditions specified in the script. The trigger is time-based, set to run weekly on Monday
Untl it's fixed, as a workaround:
if
statement at the beginning of your code that executes the rest of the code only if the last execution time (retrieved from the script properties) is not less than one week agoSample:
function sendEmailLoop() {
if(!PropertiesService.getScriptProperties().getProperty("lastExecution")){
PropertiesService.getScriptProperties().setProperty("lastExecution", new Date().getTime());
}
var lastExecution = PropertiesService.getScriptProperties().getProperty("lastExecution");
var now = new Date().getTime();
var oneWeek = 1000*3600*24*7;
if(now-lastExecution >= oneWeek){
// paste here the rest of your code
PropertiesService.getScriptProperties().setProperty("lastExecution", now);
}
}