How to automatically delete older messages in Gmail Auto Purge

sajib shahik | 12:00 AM | 0 Comments

Step by step tutorial with a procedure manual and automatic discharge of Gmail to automatically delete older Gmail. Find out more.

Gmail offers an alternative to using which you can delete messages from the Spam and Trash folder for a certain period. This option is know as Auto Purge and it is enabled by default Gmail accounts, but if your account has a relatively older, this option may not be available in your account, and as a result you may be having thousands of unread e-mails in your inbox.

Although this feature is automatically enabled on your account, the default time before the mail is removed Spams or trash is 30 days.There is one good thing about manually configure this option, which means you can add anything to a personal folder of this and together with the Spam and Trash folder, the trash is removed in a period of time, which you have set.

In this post, I'm going to tell you about the ways to manually enable this feature and Gmail account.

How to enable automatic cleaning in Gmail

By default, Gmail does not allow you to add a personal folders Auto Purge, that you need to use the script, I have added the code to write everywhere.

/ / Name Gmail label, which is intended to autopurged?
GMAIL_LABEL var = "News";
/ / Purge messages, how many days?
var PURGE_AFTER = "10";
purgeGmail function () {
var age = new Date ();
age.setDate (age.getDate () - PURGE_AFTER);
var = cleaning Utilities.formatDate (age, Session.getTimeZone (), "yyyy-MM-dd ');
var search = "label" + GMAIL_LABEL + "before" + blow;
/ / This creates a simple Gmail search
/ / Query as the label: Newsletters before: 12/10/2012
try {
/ / We deal with 100 posts of the lot to prevent script errors.
/ / Otherwise, it could throw an exception Exceed the maximum execution Apps Script
var = threads (search, 0, 100);
/ / Large lots, to create a second time trigger that
/ / Activate the automatic cleaning process after 'n' minutes.
if (threads.length == 100) {
ScriptApp.newTrigger ("purgeGmail")
. Time Based ()
. At (new Date ((new Date ()). GetTime () + 1000 * 60 * 10))
. Create ();
/ / Address yarn can be more than one message and the timestamp
/ / Individual posts can be different.
for (var i = 0, i <threads.length i + +) {
var = GmailApp.getMessagesForThread messages (thread [i]);
for (var j = 0, j <messages.length j + +) {
var email = messages [j];
if (email.getDate () <age) {
email.moveToTrash ();
/ / If the script fails for one reason or catch the exception,
/ / It will only delay the automatic purge until the next day.
} Catch (e) {}

I just put this code reference. Go to Google to drive through the link I provided, you will be redirected to this script. click File >> Make a copy and it will make a copy of the Google drive folder.

Find out the variable named GMAIL_LABEL and set the name of the folder cleaning also be set to PURGE_AFTER a number of days, you want those e-mails will be deleted.

You have to give some to use this script, go to RUN >> Initialize. Do not be afraid that you will be sharing your information with anyone after the issue of the use, your data is always safe.

Now finally go to RUN >> Install. It completes all formalities and your folder will be introduced for automatic cleaning.

If you need to remove this script, log in to Google Drive folder and go to RUN >> Uninstall.


By sajib shahik
I am a professional Graphic designer and web site designer.I always try to make my byers Happy with my work and my activities. See My portfolio.....

Stay Connected With Us
Feed Icon Twitter Icon Facebook Icon Google+ Icon Youtube Icon

Share and Spread Share On Facebook +1 This Post Digg This Post Stumble This Post Tweet This Post Tweet This Post Tweet This Post Save Tis Post To Delicious Share On Reddit Bookmark On Technorati

Related Articles


Any feedback, questions or ideas are always welcome. In case you are posting Code ,then first escape it using Postify and then paste it in the comments