简体   繁体   中英

Google Apps Script for Gmail Deletion

I use a simple Script to delete all emails after 1 day if they are labelled 'camera'. This has been working for months. I haven't changed it but it suddenly stopped working.

The script still has permission to run on my Gmail but has stopped.

Any advice appreciated.

The script is;

function cleanUp() {
  var delayDays = 1 // Enter # of days before messages are moved to trash
  var maxDate = new Date();
  maxDate.setDate(maxDate.getDate()-delayDays);
  var label = GmailApp.getUserLabelByName("camera");
  var threads = label.getThreads();
  for (var i = 0; i < threads.length; i++) {
    if (threads[i].getLastMessageDate()<maxDate)
      {
        threads[i].moveToTrash();
      }
  }
}

Thanks, Sam

您可以登录循环以检查其是否在迭代吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM