I'm very much a newbie when it comes to Google Apps Script and would love any guidance. I developed a Google Form that emails the information to a designated recipient. Essentially it is a Digital School Nurse Pass. I am getting the following error maybe once a day. In a typical day there are about 20 entries via the Google Form so I am no where near the limit. I'm assuming my coding needs to be tweaked. The error message also goes away after about 5 minutes.
Error Message
Aug 31, 2023, 3:06:01 PM Error Exception: Service invoked too many times for one day: premium email.
at digitalPass(Code:43:16)
at getFormURL(Code:28:1)
Code
function getFormURL(){ //Finds the name of the sheet connected to the Google Form
let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheets = ss.getSheets();
for (let sheet of sheets) {
let sheetName = sheet.getName();
let formUrl = sheet.getFormUrl();
if (formUrl) {
var sheetForm = sheetName;
}
}
digitalPass(sheetForm);
}
function digitalPass(sheetForm) { //Pulls the Google Form Info into an Array and sends email
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var ss = sheet.getSheetByName(sheetForm);
var ab = sheet.getSheetByName('Settings');
var lastrow = ss.getLastRow();
var passArray = ss.getRange("A2:G"+lastrow).getValues();
var recipient = ab.getRange("A3").getValue();
for (i=0;i<passArray.length;i++){
if (passArray[i][6]==""){
GmailApp.sendEmail(recipient,passArray[i][1]+" - Nurse Pass","",{htmlBody:'<b>Date/Time - </b>' + passArray[i][0] + '<br><b>Student Name - </b>' + passArray[i][1] + '<br><b>Sending Staff Member - </b>' + passArray[i][2] + '<br><b>Homeroom Teacher - </b>' + passArray[i][3] + '<br><b>Reason - </b>' + passArray[i][4] + '<br><b>Other Details - </b>' + passArray[i][5]});
var insertDone = ss.getRange("G" + (i+2)).setValue("Email Sent");
}
}
}