Automatically Archive Your Read E-mails in Gmail

Carlos S. del Castillo
4 min readJul 9, 2018

--

Updated August 13th, 2021 — available at https://bit.ly/2XgKqr0

Photo by Stephen Phillips - Hostreviews.co.uk on Unsplash

Email is now a normal part of life, we use it in our professional and personal lives. It accumulates if one is not careful. One day your mailbox has a couple of new messages and a couple of hundred old messages. The next day, you have thousands of already read messages that ‘feel’ like they are cluttering up your inbox.

Today one has many options for email services, but the most popular by a large margin is Gmail. It was reported as of October 2019 that there were over 1.5 billion users of the platform worldwide. That is more than three times the amount of its closest competitor Outlook, so this tool will be something that can be used by all Gmail users who like to keep a tidy Inbox.

The problem: How to keep my inbox clean of messages I have already read.

Solution #1 (easiest and most manual): as you read the message either trash or archive it. To do this, you need to click one of the buttons on the message menu above the message itself.

Click the archive button (in the picture above — the button inside the green circle) to archive the message. Or if you are comfortable getting rid of the message entirely click the trash button (inside red circle).

One of the major drawbacks to this solution (at least to me) is that I can’t smoothly go from one new message to the next (Google may have fixed this by the time you read this). Each time you click one of the above icons, you are returned to your inbox list of messages. If you have more than fifty (50) messages, you’ll have to go back to the last new message to read the oldest new message first.

Solution #2: Now here’s where the AutoArchiver comes in. Wouldn’t it be wonderful if Gmail were to look at your inbox periodically and see if you have any messages that you have already read that have been in your Inbox for longer than 1 day (24 hours)? This is what I sought to do. This would allow me to read my messages and give me up to a day to change my mind and do something with them. If not they would get archived and removed from my Inbox.

As I searched the internet for a solution (because I have learned that even my most brilliant ideas someone has thought of before), I found several methods but none were what I wanted. Then I came across an article by fwed titled “Auto archive emails in Gmail after 2 days”. The article essentially walked the reader through the process of setting up a script that would take messages labeled with the tag ‘autoarchive’ and have a script archive them after two days.

I grabbed his script and forked it to make a version that suited what I wanted to do. The script as it was, required that each message you wanted to archive be labeled with a unique archive tag. It would then archive the message if more than 48 hours had passed. I was looking for something a tad different.

After a couple of changes to the script, I deployed it on my Gmail account. So far it has been working with little to no issues since I put it in place back in 2018. Also, my Inbox has never been cleaner.

How to use the script in your Gmail account:

Here is how to add the script to your Gmail account. Essentially you are copying the script and deploying it to your account. Your choice.

Steps:

  1. Copy the script from GitHub.
  2. Go to script.google.com
  3. Click the ‘+ New Script’ link on the top left of the page.
  4. In the new window, highlight all the text in the script window and paste the script in its place.
  5. Click File > Save
  6. Name it gmailAutoArchiver.
  7. Click on the Run icon as above.
  8. Go through the approval screens allowing the script access to your Gmail account so it can process the messages.
  9. Click Edit > All your triggers
  10. Click the ‘Add a new trigger’ link at the bottom of the screen.
  11. The new trigger should look like this:

Click the Save button and you are all set.

Now you can enjoy your clean inbox as much as I am enjoying mine!

--

--

Carlos S. del Castillo
Carlos S. del Castillo

No responses yet