One of the things that most annoyed me when switching from Gmail to Inbox as my main email client was how you could no longer mark emails as read. My email workflow had always consisted of manually marking emails as read before archiving them, and I didn't appreciate the change. It might just be my unhealthy obsession with being unreasonably neat and organized — it probably is — but it really irks me to think that there might be an unread email hiding somewhere in my archive.

In an ideal scenario, email notifications from the Gmail and Inbox apps would have something like an "Archive and Mark as Read" button for those cases when you know right away that you can archive an email without having to read it. A decent alternative is what we already have in Gmail, where you can select a bunch of emails and, in two taps, mark them as read and archive them. However, this still requires opening the app every time, and if you use Inbox like I do, you don't even have that choice.

Fortunately, I am not the only person who suffers from this incurable malady, and after some searching around on the internet, I eventually found a much better solution — and one that works equally well for both Inbox and Gmail.

The answer I finally came across was by a guy named Mike Crittenden, who came up with it after also being annoyed by the same thing I was. His guide is pretty thorough, and the nice thing is that it uses nothing more than Google Apps Scripts. Basically, the script runs through all the unread emails in your email archive and marks them all as read in batches. This way, marking an email as 'Done' or 'archived' effectively marks them as read as well without any additional work.

After using the script for a while, I did eventually find that it ran into a bug when trying to mark more than 100 emails as read at a time — which isn't as uncommon as you might expect. Fortunately, with just a little tweak, I managed to get that ironed out and have been using the script successfully for a couple of years now.

But hey, there's no sense it keeping it all to myself; I'm sure there are several others out there who share my distaste for unread emails in their email archive, and using this little script will bring you a little more peace of mind. It takes about 2 minutes to set everything up, though it might be easier to do on a computer.

Here are the steps you need to follow.

  1. Go to the Google Apps Scripts homepage and select "New script" to create a script.
  2. Delete the sample code and replace it with the following code:
    function markArchivedAsRead() {
     var threads = GmailApp.search('label:unread -label:inbox', 0, 100);
     GmailApp.markThreadsRead(threads);
    };
  3. Save the project by clicking on File > Save and then give it an illustrative name like "Mark archived as read."
  4. Click on Run > Run function > markArchivedAsRead and select "Review Permissions" when the pop-up appears.
  5. Authorize the app you just created by selecting your Gmail account and granting it access to manage your email. You may get a "This app isn't verified" warning, but there's no need to worry: you just created this script, so it obviously hasn't been verified by Google. Just hit "Advanced" and then "Go to Mark archived as read (unsafe)" (or whatever you named your project) and you're good.
  6. Now, add a trigger to the script so it can periodically check for unread email in your archive by going to Edit > Current project's triggers and then clicking "No triggers set up. Click here to add one now."
  7. The trigger should be time-driven, and you can choose how frequently you want it to run (I have mine set to run every 15 minutes). When you've set your trigger, hit Save.
  8. Finally, save the project one more time for good measure under File > Save and close the script.

That's it. Now this little script will continue to run in the background, quietly keeping your email archive free from unread emails.