Gmail Search Syntax

Gmail offers a rich search syntax for routing through your email message archive—as if you’d expect, or indeed stand for, any less.

from:

Digs through the headers of your email message archive in search of mail sent by someone matching the keyword that you provide.

from:rael@oreilly.com
to:

The yang to from:’s yin, to: finds all messages sent to someone matching a provided keyword. (Don’t forget plus-addressing Hack #72 .)

to:engineers@example.com
to:raelity+shopping@gmail.com
subject:

Matches messages with a particular subject.

subject:"meeting notes"
label:

Looks for messages with a particular label applied.

label:knitting
has:attachment

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.

has:attachment
filename:

Finds messages with an attachment filename matching 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.

filename:meeting_notes.txt
filename:pdf
in:

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 explicitly included using in:trash, in:spam, or in:anywhere). Oddly enough, sent isn’t a usable value for in:.

in:inbox
in:anywhere
is:

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

Get Google Hacks, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.