I'm having difficulty getting my script to automatically run at around 6AM. I've set up the trigger for this script to run on a "Time-Driven" basis using the "day timer" option between 6-7 am. Despite setting up failure notifications to email me immediately, I'm not receiving any alerts and the script isn't executing as expected. When I manually run the script, it works perfectly fine, but the goal was to automate the process. I'm unsure of what I might be doing wrong in this case. I've tried deleting and re-adding triggers, following examples from others who faced similar issues, but that hasn't resolved the problem for me. Could there be something within my script preventing it from running automatically?
function getMessagesWithLabel() {
var destArray = new Array();
var label= GmailApp.getUserLabelByName('Personal/Testing');
var threads = label.getThreads(0,2);
for(var n in threads){
var msg = threads[n].getMessages();
var body = msg[0].getPlainBody();
var destArrayRow = new Array();
destArrayRow.push('thread has '+threads[n].getMessageCount()+' messages');
for(var m in msg){
destArrayRow.push(msg[m].getPlainBody());
}
destArray.push(destArrayRow);
}
Logger.log(destArray);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
if(ss.getLastRow()==0){sh.getRange(2,1).setValue('getMessagesWithLabel() RESULTS')};
sh.getRange(2,1,destArray.length,destArray[0].length).setValues(destArray);
}