Gmail Search Syntax

Gmail offers a rich search syntax for routing through your email message travel through the headers of your email message archive in search of mail sent by someone matching the keyword you provide:

from:arbabusmani@gmail.com

finds all messages sent to someone matching a provided keyword. (Don’t forget plus-addressing)

to:usmani.arbab@yahoo.com

<strong>to:TECHNICAL+books@gmail.com</strong>

Match messages with a particular subject:

<strong>subject:"Tech library"</strong>

Looks for messages with a particular label applied:

<strong>label:Krish</strong>  

<span style="text-decoration: underline;"><strong>Attachment Search</strong></span>

The has: syntax has only one possible value (at least at the time of this writing): attachment. has:attachment in a query returns only messages having one or more attachments:

<strong>has:attachment</strong>

Finds messages with an attachment filename that matches a provided pattern. Used with just a file extension (e.g., pdf or txt), filename: turns up all messages with attachments of a particular type:

<strong>filename:meeting_notes.txt</strong>
<strong>filename:pdf</strong>

Returns a list of messages in a particular collection (read: folder). Acceptable values for in: are inbox, trash, spam, and anywhere (trash and spam are not included in searches unless they are explicitly included using in:trash, in:spam, or in:anywhere).

<strong>in:inbox</strong>
<strong>in:anywhere</strong>

Acceptable values for is: are starred, unread, and read, which return starred, unread, and read messages, respectively:

<strong>is:read</strong>

Finds messages carbon copied to particular recipients:

<strong>cc:apple@gmail.com</strong>

Finds outgoing messages blind carbon copied to particular recipients.

Note that bcc: doesn’t work on any incoming mail because there’s no way to tell who’s on the bcc line:

<strong>bcc:apple@gmail.com</strong>

Match messages sent or received before a particular date, specified in yyyy / mm / dd format. Unfortunately, partial datesyear only or year and monthdon’t find anything at all:

<strong>before:2008/10/02</strong>

Match messages sent or received on or after a particular date, specified in yyyy / mm / dd format:

<strong>after:2008/11/21</strong>

Phrase Searches

Enclose phrases in double-quotes (") to have the Gmail search treat them as a unit to be matched exactly (case isn’t taken into account). The following query finds only accounting department reports:

<strong>Subject:"THL report"</strong>

Basic Boolean

The only Boolean operator supported by Gmail search is OR (uppercase is required). In the absence of the OR operator, AND is implicit.

The Boolean OR operator works in Gmail searches just as it does in Google Web Search: specify that any one word or phrase is acceptable by putting an OR between each, such as in this query, which finds all messages from the boss or messages with subjects marked as urgent:

<strong>from:krishna@gmail.com </strong><strong>OR subject:pictures</strong>

Negation

The negation operator ( ) also works as it does in Google Web Search, excluding messages matching the negated keyword or operator : keyword pair. So the following query turns up all messages to Example

<strong>to:@gmail.com -from:alert@</strong>

Grouping

Parentheses are used a little strangely in Gmail queries. When enclosing a set of words, they specify that each word must be found to be considered a match. So the following matches messages sent to both dev and THL:

<strong>to:(dev THL)</strong>

Throwing in an OR allows optional matches while being explicit about groups of options; while we humans tend to be able to parse precedence without the need of parentheses, search engines require a little more help. The following query finds all messages sent to arbab about posts or THL:

<strong>to:krish subject:(posts </strong><strong>OR THL)

</strong>