daily pastebin goal
34%
SHARE
TWEET

Delete Me

a guest Nov 20th, 2013 1,636 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function auto_delete_mails() {  
  2.   var label = GmailApp.getUserLabelByName("Delete Me");  
  3.   if(label == null){
  4.     GmailApp.createLabel('Delete Me');
  5.   }
  6.   else{
  7.     var delayDays = 2 // Enter # of days before messages are moved to trash  
  8.     var maxDate = new Date();
  9.     maxDate.setDate(maxDate.getDate()-delayDays);    
  10.     var threads = label.getThreads();  
  11.     for (var i = 0; i < threads.length; i++) {  
  12.       if (threads[i].getLastMessageDate()<maxDate){  
  13.         threads[i].moveToTrash();
  14.       }
  15.     }
  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