How do I get the remaining daily mail quota of google apps scripts service to work consistently?

I did a project on google apps scripts to send automatic emails after a form response was sent. However, when I check the daily quota of remaining emails with the MailApp.getRemainingDailyQuota() method, the quota responses vary with each script execution.

So I created another project just to test the quota, using the MailApp.getRemainingDailyQuota() method and even so, the quota response varied with each execution.


Code used to test:

function testeDeCota() { 
  let cota;

  cota = MailApp.getRemainingDailyQuota();
  Logger.log("Cota de emails restantes: " + cota);

  cota = MailApp.getRemainingDailyQuota();
  Logger.log("Cota de emails restantes: " + cota);

}

I am using a workspace account that has a quota of 1500 emails/day.

This is a screeshot of my executions. Note that there are 3 consecutive executions and without sending any email, even so the quota responses varied. The responses were:

1394;
1399;
1390.

Whenever I try to send an email or get the quota information the number just vary randomly.

printscreen of the script executions

43 thoughts on “How do I get the remaining daily mail quota of google apps scripts service to work consistently?”

Leave a Comment