1

I am a true novice at this. Needed a solution to clean up my gmail.

After searching found the script below. I created filters that send emails to the "delete me" label. I added the script to my projects and published giving it access to my gmail. I also set up a hourly trigger. The filters are working well and the script is running based on the log but no emails are getting deleted.

Can anyone tell me what's wrong? (I made a similar one for a label called "archive me" and this is also not working).

Thank you

function cleanUp() {
var delayDays = 60

var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays);

var label = GmailApp.getUserLabelByName("delete me");
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
if (threads[i].getLastMessageDate()<maxDate)
  {
    threads[i].moveToTrash();
  }
 }
}

0 Answers0