Inspiration / The Problem

I built Declutter to help me automatically move emails from specified addresses to trash every 2 days. I was receiving more than 200 emails every week and previously had to manually delete them to ensure my mailbox doesn't become too cluttered.

Before Declutter, I wanted a way to automatically delete these emails since most of them were from my banks or social media and I only needed to read them once. When I searched online for services that could help me delete my emails, I discovered that I had to pay for them, and worse, I had to grant those services permission to read my emails, which is something I do not want. With Declutter, I don't have to pay money or grant read permission to any company at all.

What It Does

Declutter is designed to help anyone move emails from any email addresses they specify to trash automatically. Users also get to see logs showing the emails that were moved to trash when Declutter runs. This is super important in case an email that wasn't supposed to be trashed gets trashed. There's also a 1-click disaster recovery feature to help restore any or all emails that were trashed when Declutter ran.

How I Built It

I built Declutter as a container-bound Google Apps Script inside Google Sheets, meaning it runs entirely inside your own Google account and no external servers or databases ever touch your emails.

Under the hood, running on Google's modern V8 engine, it compiles custom retention rules into safe Gmail search queries that automatically protect starred and exempt messages.

The engine uses the Gmail API to soft-trash matching threads in batches of 50, stamping each batch with a temporary run label so you can restore everything in one click if a rule misfires.

To prevent race conditions, I used a LockService mutex that stops the automated 2:00 AM daily trigger and manual sidebar cleanups from stepping on each other. The sheet itself serves as both the relational database and audit log, tied together with a lightweight HTML sidebar for non-developers.

Challenges I Faced

The biggest challenge I faced was deciding how to handle the "Google hasn’t verified this app. The app is requesting access to sensitive info in your Google Account. Until the developer verifies this app with Google, you shouldn't use it" warning Google shows anyone when they run Declutter in their Gmail accounts. In the end, I decided to clearly explain why Google shows this warning: because Google wants me to pay for a CASA audit. Plus, I also made it clear that Declutter lives inside users' own Gmail accounts, so there's absolutely no way for me to read their emails.

Accomplishments That I'm Proud Of

I'm proud of the fact that building and maintaining Declutter costs me nothing at all. This allows me to offer Declutter for free to my friends, family, and anyone else.

What I Learned

I learned about Google Apps Script. Before building Declutter, I had never heard of Apps Script. But now, I know what Apps Script is and how it works. Plus, I'm pretty sure I'm going to use it again in the future.

What's Next for Declutter

Nothing much. I intend to build maybe one or two features if I get a really good idea.

Built With

Share this project:

Updates

Submission history