Automatically label lingering emails with this Google Apps ScriptPosted: April 5, 2013
I try to keep my inbox clean, and for the most part I do a pretty good job at it. There’s one bad habit I have, though. I star emails in Gmail so I’ll remember to follow up with them later, and then I never get around to it. Emails just keep getting pushed further down the list and piling up. I can’t deal with all emails right away, but after a while they just stick around because I’m avoiding making a decision on them. What I need is a way to automatically to something give myself a little nudge after a certain amount of time. A little push that will remind me that those emails aren’t going to just answer themselves.
I was able to write a couple of functions to automatically add a label to any items that were in my inbox that also had a star label. When I remove the star, or archive the email, the label is removed. Here’s what the output looks like.
Here’s how I set it up
Go to script.google.com, and create a new project. I called mine “Add nagging label for old starred items”
Paste in the following code
[updated 4/23/13 to fix a bug that was causing un-starred threads to not have the label automatically removed]
Save the script, then test to make sure the scripts are working by selecting the “addNaggingLabels” or “removeNaggingLabels” functions from the dropdown in the script editor toolbar, then clicking the arrow to run them. You’ll be asked to allow the script to be run on your inbox before you can test it out. You should only have to do that step once.
When the “Deal with me” label gets created, it won’t be red by default. You’ll have to go find it in the left sidebar of your Gmail inbox and click the arrow next to it to manually change the color to red (or some color you really hate. Whatever will be the most motivating).
Finally, click the “triggers” icon, and set up the following triggers so both functions run every hour.
That’s really all there is to it. Now, I get a nice big red label automatically added to any stale starred items. It doesn’t totally prevent things from piling up, but it helps give me that little prod to make an effort to keep things tidy.