Gmail provides an auto-delete feature for two of its folders - Spam and Trash. That means messages in these folders which are older than a particular date (30 days) will get deleted automatically. This is an excellent feature that avoids accumulation of unwanted mail.

Almost all of use use labels to organize emails better and create filters that move matching emails to these labels on arrival. But Gmail doesn't allow the same auto-delete feature to be used on any other folder or label. And most of the time, there would be one or more labels for those not-so-important mails which you just want to read but not store. Here's a simple trick to add an auto-purge feature to any Gmail label so that mails in the label will get deleted automatically after a fixed time which you can choose.

Auto Delete Emails in Labels After a Fixed Time.

We will be using a Google script to do this which you need to activate and run once. The only requirement is that you should have a Google drive account. If you don't have one, just to to drive.google.com and sign up for one.

  1. First open this Google Script and select File -> Make a copy. This will create a copy of the script in your Google drive and open it.
  2. Set the value of "LABEL_TO_DELETE" with the label you want to enable auto-delete and "DELETE_AFTER_DAYS" with the age of an email in days after which it should get deleted.
  3. Select Run -> Initialize. Google will ask you to grant required permissions. The script will be running for only your personal account, so nobody else will have access to your data.
  4. Select Run -> Install. This will install and start the script for your account.

You are now all set. The emails in the label you specified will now get deleted automatically once they age out with the number of days you chose. Just make sure you don't delete the script from your Google Drive. Also, if you want to stop purging mails any time, just open the script once again from your Google drive and select Run -> Uninstall.

TIP: If your label is a nested label, you need to give it in the format "parent/child" where "parent" is the main label and "child" is the nested label.

Also See: How to block any person in Gmail.