Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement