Maintaining your inbox clean can be hard, as previously explained. The method described below makes it easier and only uses a Gmail label to automatise the archiving process on certain types of emails (newsletters, notifications, emails digests, etc).
Please bear in mind it’s a method to keep your inbox cleaned over time onward, this is not a method to get rid of the 20K unread and useless emails piling up in your inbox that you accumulated for the last 10 years.
Create an ‘autoarchive’ label
- Go to your Gmail Settings
- Click the Label tab
- Hit the Create new label button
- Name it autoarchive
Use Gmail filters to apply the ‘autoarchive’ label
Let’s say you want each notification you receive from Facebook to be automatically archived after 2 days. Follow the next steps to create a Gmail filter which is going to apply the ‘autoarchive’ label to these Facebook notifications.
- Open any email from Facebook
- Click on More in the top bar
- Click on Filter messages like these
- Then hit the Create filter with this search
- On the next screen, tick the Apply the label box, and select the autoarchive label
- Before you finish, tick the box Also apply to matching conversations at the bottom of the form
- Hit the Create filter button
From now on, all the emails received from Facebook will be labelled with the ‘autoarchive’ label. You can repeat that process to any other recurrent emails you get (Spotify notifications, Quora digests, LinkedIn recruiters, WordPress comments, etc).
Use a Google Script to archive daily
Follow the next steps to create a Google Script of your own and use the piece of code shown below:
- Go on script.google.com
- Copy and paste this code from GitHub into your Google Script
- Click File > Save
- Name it gmailAutoarchive (it will be saved in the root folder of your Google Drive)
- Go in the Run menu, then select gmailAutoarchive
- Google Script will require access to your Gmail (see screenshot below). Click Review Permissions.
7. Another window will appear, click Allow
Make sure it worked
First, bear in mind the Google Script I made only applies to emails that are at least 2 days old (48 hours). Also, the script does not go further back than 400 emails.
Now, to make sure it worked, follow the next steps.
- Go into your autoarchive label/folder to see all the emails it contains
- Check that all the emails older than 2 days do not have the ‘inbox’ label (meaning it has been archived)
If you still see emails that are more than 2 days old and that are labelled ‘inbox’, it could mean there are too many emails (the script only goes back to the previous 400 emails).
Setup a daily trigger
Within your Google Script window:
- Click on Edit > Current project’s triggers
- Then add a new trigger with the following settings: Time-driven, Hour timer, Every 12 hours
This will check every 12 hours if there are new emails to archive. See screenshot below.
Tweak and customise the script
Having the script shown below as a base, you could code several and useful tweaks in order to:
- only archive the unread emails
- archive all emails regardless of the autoarchive label
- archive emails only if you starred them
Or anything else you feel like would help to keep your inbox clean!
I am keen on knowing if this solution is working for you, or how you adapted it to suit your needs. Questions? Comments? Leave a note here or email me at email@example.com