Using this script, you can schedule an add-on in Gmail that automatically checks your mailbox at 2 am GMT every day and deletes the emails labeled Auto Delete
. You can also set custom retention periods for different types of emails; for instance, you can configure to delete Amazon order updates after 30 days whereas delete Google Security Alerts after just 7 days.
Go to script.google.com
Create a New Project and rename it as Auto Delete Emails
In the code editor, copy and paste the script from the below Github page and save the project.
Once the project is saved, select the installAddon
function and click Run
Give the necessary permissions to allow the script to access your mailbox.
Once the installAddon
function finishes running, you should have Auto Delete
label added to your mailbox with three nested labels.
Auto Delete/7
, the email will be deleted once it’s 7 days old.
Assign the labels to the emails. You can also use the Filters functionality to ease the process. Yay, you are all set. The emails assigned with Auto Delete
-based labels will be deleted the next time the add-on runs based on their retention periods.
Auto Delete
without any nested label, it will be deleted when the add-on runs at 2 am GMT.Auto Delete/7
, it will be deleted if it is 7 days old.You can remove the add-on by going to your project in script.google.com and running the deleteAddon
function.
No, all the processes happen within your Google ecosystem. The developer doesn’t have access to any kind of data.
The script deletes only emails labeled as Auto Delete
. The developer is not responsible for any emails deleted by mistake.