Monday, 22 May 2017

Add the Auto-Sweep Feature of Outlook to Gmail

Outlook has an interesting Auto-Sweep feature that automatically deletes older email messages from specific senders after a certain period of time. The Trash and the Spam folders in Gmail too have a similar auto-purge property and any mail in these folders that is older than 30 days is automatically deleted.




GMAIL AUTO PURGE – DELETE OLD MAILS AUTOMATICALLY

Auto-purging can help keep your mailbox lean and tidy.

For instance, if you have created a rule in Gmail that archives all your newsletter subscriptions to a particular label, these unwanted messages will live forever until you manually purge them. With auto-purging enabled, the older mails of a label are automatically removed from your mailbox.

HOW TO ENABLE AUTO-PURGING IN GMAIL

You can’t enable auto-purging in Gmail for any particular label but there’s a simple Google Script that will bring this missing functionality to your Gmail. The script will basically monitor messages belonging to a particular folder /label in Gmail and purge those that have exceed the retention time.

Here’s how you can get auto-purge to work inside your Gmail:

1. Copy this Google Auto-Purge Script into your Google Drive.

// The name of the Gmail Label that is to be purged?
var GMAIL_LABEL = "Newsletters";    


// Purge messages automatically after how many days?
var PURGE_AFTER = "10";



/*

  


  T U T O R I A L
  - - - - - - - - 
  
  Step 1. Update the values of fields GMAIL_LABEL and PURGE_AFTER above.
  
  Step 2. Go to Run -> Initialize and authorize the script.
  
  Step 3. Go to Run -> Install to install the script.
  
  You can now exit this window and any email messages in Gmail folder will automatically 
  get purged after 'n' days. The script will run by itself everyday at 01:00 hours.
  
  Also, you may go to Run -> Uninstall to stop the purging script anytime.





























*/






function Intialize() {
  return;
}

function Install() {

  ScriptApp.newTrigger("purgeGmail")
           .timeBased()
           .at(new Date((new Date()).getTime() + 1000*60*2))
           .create();
  
  ScriptApp.newTrigger("purgeGmail")
           .timeBased().everyDays(1).create();

}

function Uninstall() {
  
  var triggers = ScriptApp.getScriptTriggers();
  for (var i=0; i<triggers.length; i++) {
    ScriptApp.deleteTrigger(triggers[i]);
  }
  
}

function purgeGmail() {
  
  var age = new Date();  
  age.setDate(age.getDate() - PURGE_AFTER);    
  
  var purge  = Utilities.formatDate(age, Session.getScriptTimeZone(), "yyyy-MM-dd");
  var search = "label:" + GMAIL_LABEL + " before:" + purge;
  
  try {
    
    var threads = GmailApp.search(search, 0, 100);
    
    if (threads.length == 100) {
      ScriptApp.newTrigger("purgeGmail")
               .timeBased()
               .at(new Date((new Date()).getTime() + 1000*60*10))
               .create();
    }
    
    for (var i=0; i<threads.length; i++) {
      var messages = GmailApp.getMessagesForThread(threads[i]);
      for (var j=0; j<messages.length; j++) {
        var email = messages[j];       
        if (email.getDate() < age) {
          email.moveToTrash();
        }
      }
    }
    
  } catch (e) {}
  
}

2. Set the value of GMAIL_LABEL to the label that you wish to auto-purge and PURGE_AFTER are the number of days for which you to retain a message in Gmail.

3. Go to Run -> Initialize and grant the necessary permissions. This is your personal script and nobody else will ever have access to your data.

Go to Run -> Install to install the auto-purge script.

That’s it. Exit the Google Script and it will continuously monitor that particular Gmail label in the background. If you need to disable auto-purging later, just open the same script in your Google Drive and choose Run -> Uninstall.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Labels

404 AdBlock Add-on Airtel GPRS Trick Airtel SMS Trick Alexa Amazon Amazon Kindle Amazon Prime Android Android 8 Android Oreo antivirus Apple Apple Mac ASCII Audacity Audio Authotkey Backup Balance Transfer in Vodafone Battery Bing Blogger Blogging Bookmarklet Browser Camera Chromebook clock Cloud colors command lines Computer Computer Tricks configuration Contact Creative Commons Credit Card CSS devolop DIY Doodle DOS Download Dropbox E-Mail eBook Email Email Attachment Embed Encryption English Error Evernote Eyes Facebook Facebook Tricks Feedburner Flipkart Font Foursquare Free Internet Free sms trick in Vodafone G Mail Gadget Game Getty Images GIF Gists Github Google Google AdSense Google Analytics Google Apps Google Chrome Google Contacts Google Currents Google DNS Google Docs Google Drive Google Earth Google Font Google Forms Google Images Google Map Google Photos Google Play Store Google Plus Google Print Google Reader Google Script Google Sheets Google Spreadsheet Google Translate GPRS Setting GPS Hacking Health App HelloFax Hindi Hoodie HTML Icons idea Image Editing Images IMEI Indian Railways Infographics Instagram Internet Internet Explorer Internet Tricks iOS iPad iPhone IRCTC iTunes iTV JavaScript JioCinema JioTV Junglee Kindle Language Translation Laptop Laptop. TV Life Time FREE GPRS Life-Style Link Linkedln Linux logo Make Money Online Microdoft Powerpoint Microdoft Word Microsoft Office Microsoft Outlook Mobile Mosaic Music Name Networking nexus Notepad OCR Online Shopping Open DNS OS Outlook Password PDF Petya Phillips Hue Lights Photogtraphy Pixel Play Station Podcasts Pokemon Pokemon Go Polls Print Productivity Proxy Server Pushbullet QR Code Ransomware Reddit Reliance Hack GPRS Reliance Jio RGB Ringtone Router RSS Safe Mode Samsung Galaxy S Scrabble Screen Capture Screen Sharing Screencast Secrets Security Send free sms from PC SEO Sierra Skype Slideshare SMBv1 SMS Snapchat Snapdeal Social Media Solution Sound Device Speech Recognition Sql Steam Sync Synology NAS Tata Docomo GPRS trick Teleprompter Torrent Trick Tricks TV Twitter UltraISO Unicode Unknown Extension Unlimited 2GB Unlimited 3GB Unlimited GPRS USB USB Security Key Video Editing virtual desktop Virus attack VLC Vodafone 110% working trick for GPRS Vodafone 3g Vodafone GPRS VPN wallpapers WannaCry Web Design Web Domain Website Wget Whatsapp WiFi Wikipedia Windows Windows 10 Windows 10 S Windows KN Windows Tricks windows updates Winows N Wolfarm Alpha WordPress XBox YouTube Zip
Twitter Delicious Facebook Digg Stumbleupon Favorites More