How to auto delete old mail in gmail
Gmail allows you to automatically delete old emails using filters. Here's how to do it:
Method 1: Using Gmail's built-in feature
- Log in to your Gmail account.
- Click on the gear icon () in the upper right corner and select "See all settings."
- Go to the "Filters and Blocked Addresses" tab.
- Click on "Create a new filter."
- In the "From" field, enter
older_than:<number>days
(e.g.,older_than:30days
to delete emails older than 30 days). - Click "Create filter."
- In the "Apply the label" dropdown menu, select "Delete it."
- Click "Create."
Method 2: Using a third-party add-on
- Install the "Snooze" add-on from the Google Workspace Marketplace.
- Log in to your Gmail account.
- Click on the Snooze icon () in the upper right corner.
- Click on "Settings" and then "Filters."
- Click on "New Filter."
- In the "From" field, enter
older_than:<number>days
(e.g.,older_than:30days
to delete emails older than 30 days). - Click "Create filter."
- In the "Apply the label" dropdown menu, select "Delete it."
- Click "Create."
Method 3: Using a script
-
Enable the "Script Editor" in your Gmail account by going to the gear icon () > "See all settings" > "Labs" and enabling "Script Editor."
-
Create a new script by clicking on the "Create" button.
-
In the script editor, paste the following code:
function deleteOldEmails() { var threads = GmailApp.searchThreads('older_than:<number>days'); for (var i = 0; i < threads.length; i++) { threads[i].delete(); } }
Replace
<number>
with the number of days you want to delete emails older than. -
Save the script by clicking on the "Save" button.
-
Set up a trigger to run the script at the desired interval (e.g., daily) by clicking on the "Triggers" tab and creating a new trigger.
Note: Before deleting old emails, make sure to backup your important emails or use a third-party add-on like "Snooze" to move them to a separate label instead of deleting them.