Maintaining Gmail filters with XML

Posted by Matt Thommes on March 22, 2009 | Post type: Gain

I'm a very organized email user. I like my inbox as tidy as possible. Everything that comes in must either get archived, acted upon (replied, added to To-Do list, etc), or deleted.

But I'm also lazy. I use Gmail keyboard shortcuts extensively, in order to quickly move through my email. I like to get in, read what's there, and get out. The less time spent mucking around my inbox, the better.

That's why I love the recent Gmail Labs feature that allows you to import and export your email filters.

Creating email filters is time-consuming. It's a few step process, and when you're done, you've only set up a single filter. What if you have five or ten to set up? I'd rather spend time editing a single source than clicking back and forth endlessly through an application.

With the ability to export my Gmail filters as an XML file, I can now quickly edit the XML document, and re-import, as many times as needed.

Here is the XML structure for a new filter item:

<entry>
    <title>Mail Filter</title>
    <apps:property name='from' value='joe@site.com'/>
    <apps:property name='label' value='Web'/>
</entry>

Here we are setting up a filter to capture incoming email from joe@site.com, and applying a label of "Web." Just like the Gmail process of setting up new filters, you can apply as many labels as you want, as well as other directives, such as sending directly to Trash:

<apps:property name='shouldTrash' value='true'/>

... or immediately archiving:

<apps:property name='shouldArchive' value='true'/>

Mark as read:

<apps:property name='shouldMarkAsRead' value='true'/>

Matching a sequence of letters or words:

<apps:property name='hasTheWord' value='FW:'/>

You can mix and match any combination of apps:property elements until you've created the filter you desire.

Then, save the file and import back into Gmail:

Screenshot of Gmail

Import and export as often as needed. Share useful filters with other Gmail users. Have a single file for maintaining filters.

About the author(s)

Matt Thommes is an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from a suburb of Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Comments

Note: Comments may be viewed by authors, but if you have a more specific question you'd like to ask them, please email matt.thommes@paininthetech.com.

# cheesmo at 4/2/2009 7:19 am cst
THANK YOU! THANK YOU! THANK YOU! THANK YOU! Very niiiice. I just used this this morning. I was getting lots of crap on my BlackBerry. It's never bothered me that much before, but when it's on your phone it's a constant pain in the butt to get so many target mailings.

Quick Link to this comment: http://TTIP.me/c5024