Here is a Google Script for using SaneBox alongside

A Google Script to use SaneBox alongside to manage email newsletters

A Google Script for using SaneBox alongside Unroll.meI’ve written before about my drive towards living the Inbox Zero methodology and my experiment in reducing my emails by a quarter.

Two tools that I use to stem the tide of emails I receive are the excellent SaneBox and Here’s a guide to using SaneBox alongside

SaneBox and

SaneBox is a fantastic tool that sits between my inbox and me and filters mail into various folders to help me to prioritise my email consumption. For instance, any email newsletters I receive are removed from my inbox and pushed into the @SaneNews sub-folder — so I can deal with them in batch and without them distracting from my important emails. is another super free tool that captures any email newsletters I subscribe to and rolls them up into a daily digest. I can then scan read this digest at my leisure, rather than opening and closing each individual email newsletter.

Using SaneBox alongside is very useful to me.

Using SaneBox alongside

Unfortunately, SaneBox and don’t seem to plSaneboxay well together. SaneBox wants to move email newsletters to its @SaneNews folder, and wants to archive the messages in Google Mail. The end result is that I get both digest emails and (albeit marked as read) email newsletters in my @SaneNews folder.

It’s hardly the end of the world, but it is an irritation for me to have to select all the “read” email newsletters each day and manually remove the @SaneNews label in GMail.

Surely there is an automated way of doing this?

SaneBox and don't seem to play well together. Here's a Google Script to help Click to Tweet

A Google Script to remove emails from @SaneNews

Thanks to a blog post by Fwed on Medium, and a Google Script by Amit Agarwal from StackOverflow that I’ve modified, there is.

Follow these steps to create a Google Script for your own Google Mail:-

A Google Script for using SaneBox alongside

function archiveYThreads() {
var label = GmailApp.getUserLabelByName(“@SaneNews”);
var threads =‘label:””‘);
for (var i = 0; i < threads.length; i++) {

  • Click File > Save
  • Name it Gmail AutoArchive for (the script will be saved into the root folder of your Google Drive)
  • Click the Run button
  • Google Script will ask you for access to your Gmail. Allow this and proceed.

Give the script a few seconds to run, and you should notice that any emails in your @SaneNews folder that are labelled “” disappear — archived away.

Finally, to set this script to run automatically in the background:-

  • Within your Google Script window, click on Resources > All your triggers
  • Add a new trigger with the following settings: Time-driven, Minutes timer, Every 15 minutes.

Every 15 minutes, Google Script will scan your @SaneNews folder and if it finds any messages processed by, it will remove the @SaneNews label and archive the messages.


I’m absolutely no Google Script expert, and I created this script through simple trial and error using the work Fwed and Amit Agarwal provided as a basis. If anybody with more experience than me with Google Scripts would like to suggest any modifications or updates, please leave a comment below or get in touch with me. As it is, the script seems to work for me at least.

I hope any other SaneBox and users find this script useful!

You Might Also Find Interesting


    Reader Interactions

    Leave a Reply

    Your email address will not be published.

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Send this to a friend