Skip to main content

Hack Attack: Build advanced Gmail filters and persistent sear...

Popularity Report

Total Popularity Score: 0

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Rank

Bookmark History

Saved by 55 people (-19 private), first by anonymouse user on 2007-07-10


Public Sticky notes

Yeah I'd really like a filter action like "mark as not spam". Or how about: if my filters match it and I'm applying a label to it already, it's not spam.

Highlighted by mikecsees

Gmail

Highlighted by hielo777

When you construct a complicated query in Gmail, the search terms are all by default grouped with AND, meaning that every match to a search like to:adam subject:iPhone is both to me and has iPhone somewhere in the subject. The Gmail documentation recommends using the OR operator when only one term needs to match. Our search might then become to:adam OR subject:iPhone, meaning that every match is either addressed to me, has iPhone in the subject, or both.

Highlighted by wisely

Instead, surround the disjunctive search terms with curly brackets {}. Searching Gmail with {to:adam subject:iPhone} will yield the same results as the OR search above while allowing you more room for tweaking the terms and saving you from typing an endless string of ORs. Everything inside the curly brackets is assumed to be linked with OR.

Highlighted by wisely

Similarly, search terms surrounded by parentheses () group every item with an AND. Granted, AND is the default for search terms, but parentheses can still come in very handy when things get complicated. For example:

Highlighted by wisely

{to:(adam@lifehacker.com tips@lifehacker.com) subject:Quicksilver}

Highlighted by wisely

Using either the persistent search Greasemonkey script or the Better Gmail Firefox extension with persistent searches enabled, you can create and save persistent searches in Gmail that work like Gmail labels, except that they're dynamic.

Highlighted by wisely

Filters and building large queries

Highlighted by wisely

expanded-filter.pngFilters come in handy when you want to perform certain actions on email when it arrives—actions like archiving, forwarding, and labeling.* If you're planning to set up complex filters, the first thing you should do is expand Gmail's filter input,** turning it from a one-line input box to a textarea. That way you can

Highlighted by wisely

Since Gmail search operators work in filters, you can forego the other filter inputs and push your query into the Has the words field (or not, depending on which you prefer).

Highlighted by wisely

-from:{ *@lifehacker.com *@gawker.com *@gizmodo.com *@defamer.com *@wonkette.com *@idolator.com *@fleshbot.com *@kotaku.com *@deadspin.com *@gridskipper.com *@consumerist.com *@valleywag.com *@jezebel.com }

As you can see, this query uses the hyphen -, which negates the content of the following curly bracketed section. In my example, any email that does not match one of these handles (i.e., any email not sent from A or B or C...) gets archived and labeled "Lifehacker Tips." If I decide a contact has earned inbox status, I can just add their email to the end of the list (luckily Gmail doesn't remove the line breaks so the query retains its friendly format when I need to edit it).

Highlighted by wisely