SHARE
TWEET

Untitled

a guest Apr 24th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function GmailIndef() {
  2.   var INDEF_LABEL = 'Indef';
  3.  
  4.   var RETENTION_DAYS = 356;
  5.   var RETENTION_DATE = new Date();
  6.   RETENTION_DATE.setDate(RETENTION_DATE.getDate() - RETENTION_DAYS);
  7.  
  8.   var threads = GmailApp.search('in:anywhere'
  9.                   + ' -(label:' + INDEF_LABEL + ')'
  10.                   + ' before:' + RETENTION_DATE.getFullYear()
  11.                           + '-' + (RETENTION_DATE.getMonth() + 1)
  12.                           + '-' + RETENTION_DATE.getDate());
  13.  
  14.   threads.forEach(function(thread) {
  15.     GmailApp.moveThreadToTrash(thread);
  16.   });
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top