Skip to main content

Set Gmail To Auto-Delete Emails Older Than A Set Number Days

Set Gmail To Auto-Delete Emails Older Than A Set Number Days

February 23, 2013 at 07:00PM

A few days ago, we reviewed Mailstrom, an amazing web service that helps you clean your messy inbox. It’s an amazing service that can help tame even the wildest inboxes and it’s worked great for us. Once your inbox is clean though, you might want to keep it clean. The simplest way to do that would be to read your email regularly, archive the messages you want to keep and delete the useless ones. Of course, if it were really that simple, we wouldn’t have messy inboxes to begin with. If you’re often unable to remove read messages or unimportant ones from your inbox, you can use the following Google Script to automate it for you.

To use this Google Script, you need to first filter out the messages that you are mostly unable to read (and those that are generally useless for you). If you’ve never created a filter before, here’s how: click the cog wheel icon at the top-right corner of Gmail’s web interface and select Settings. Here you will find a lot of tabs. Go to the Filters tab and click the ‘Create a new filter’ link at the bottom. The search bar will expand with fields for the filters you can apply.

We created a filter for email addresses (From, To). You can create a similar filter for the Subject too if you like. Label your filter “delete me” and apply it to all existing messages.

Next, go to Google Scripts and create a blank project. Paste the following script in the new file and save/run it from the Run menu.

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

Next, you need to set triggers for this script, i.e., how often it should run in a day. Go to Resources >Current project’s triggers and set it to run either on a per-minute, hourly, or daily basis. Now choose how often within the selected interval the script should run. We set it to run every other minute, which is more frequent than the regular user’s requirement. You can set it to run every 12 or 24 hours to make sure the messages are sent to Trash everyday.

script triggers

That’s about it. Run the script and you will see all emails with the “delete me” label have been moved to Trash. You can change how long an email stay in your inbox before this script sends it to Trash by editing the following this line in the script:

  var delayDays = 2 // Enter # of days before messages are moved to trash  

Replace the 2 with a higher number or even with 0 so that all emails with the “delete me” label are sent to Trash within the current day.

[via Lifehacker]

Read Set Gmail To Auto-Delete Emails Older Than A Set Number Days by on AddictiveTips - Tech tips to make you smarter

from AddictiveTips

Popular posts from this blog

Ten Apps you Must Download when you Buy A New Android Smartphone

Ten Apps you Must Download when you Buy A New Android Smartphone

May 14, 2013 at 11:21PM You have spent loads of time researching which is the best Android smartphone that fits your budget, spoken to people in the know about gadgets and have saved accordingly. After contemplating a fair bit if this is the right time to pick a device and there is no other device you would rather have, you take a plunge into the astonishing world of Android and pick that shiny new Android device. Right now it is sitting proudly in your hands as you admire every curve, every pixel, visible or not of your new Android smartphone.It is the time to load your Android smartphone, to make it truly yours, a device that would be with you through your thick and thin. Time to install those applications which will complete your world, if not complete, at least make your world a lot more organized and a lot more fun. So which apps do you start off with?Like the famous Nokia commercial goes, you have our back. Here …

How to Password Protect & Encrypt Files [Mac/Windows]

How to Password Protect & Encrypt Files [Mac/Windows]

May 16, 2013 at 06:33PM Nowadays, the computer has a very important place in everybody’s life, as a personal gadget used for a lot of different things. Everything is digital and it is stored on a computer’s hard-disk or on a cloud system, offering you easier access to your favorite data.Computers have become the place where you hold pictures, documents, favorite music and everything else in the same place. While storing may include regular data, random and even useless information, people may also keep important stuff, such as wedding photos, work documents, projects and others.Have you ever thought about protecting critical data with a password? Taking into consideration that all information could be vulnerable to hackers or to unauthorized persons, this is a rather obvious procedure. Another reason to encrypt data can appear in case somebody else also uses that computer and you don’t want them to have access to private pict…

5 Awesome Search Tools for Twitter

5 Awesome Search Tools for Twitter

April 20, 2013 at 07:40PM Twitter is undoubtedly one of the most popular social networking and micro blogging tool today. Ever since its launch in 2006, it has grown rapidly. The service rapidly gained worldwide popularity, with over 500 million registered users as of 2012, generating over 340 million tweets daily and handling over 1.6 billion search queries per day. So if you have been a Twitter user for long time, you might already know searching for any tweets or mention from the timeline is not possible. For this you will need dedicated search tools.So if you want to do an advanced search on Twitter, here are some best tools to get started.Related Reading:Ways to Search Twitter1. Twitter Search:Twitter has a default search tool which is pretty good to search for old tweets. It also has an advanced search where you can select people, places, etc. to search tweets. You can also use operators for search.2. SnapBird:SnapBird is a powerful search en…