# Gmail Search Operators for Building a Contact List

> A working reference for the Gmail search operators that define a contact list: labels, senders, dates, categories and attachments - plus the combinations that actually scope an export.

- Source: https://www.8apps.co/blog/gmail-search-operators-build-contact-list
- Markdown: https://www.8apps.co/blog/gmail-search-operators-build-contact-list.md
- Published: 2026-09-01
- Author: 8apps Team
- Language: en

---
Most guides to Gmail search operators are written for finding *one* email. This one is written for the opposite job: defining a **set** of messages precisely enough that the addresses inside it are worth collecting.

That changes which operators matter. `is:starred` is excellent for finding a thing you starred. It is nearly useless for defining a list, because you starred those messages for unrelated reasons.

---

## The operators that define a set

These five do almost all the work.

### `label:` — the strongest signal you have

```
label:clients
label:conference-2026
```

A label is a decision you already made about which messages belong together. If you have been labelling consistently, this single operator does more than the other four combined.

Multi-word labels need quotes: `label:"Q3 pipeline"`. Nested labels use a dash: `label:clients-enterprise`.

### `from:` and `to:` — including whole domains

```
from:jane@acme.com
from:@acme.com
to:sales@yourcompany.com
```

The domain form is the useful one. `from:@acme.com` maps everyone at a company who has written to you — which is often the actual question behind "who are our contacts at Acme?"

### `newer_than:` / `older_than:` — relative windows

```
newer_than:6m
older_than:2y
```

Units are `d`, `m`, `y`. These are **relative to today**, which is what makes them the right choice for a recurring export: `newer_than:6m` still means "the last six months" a year from now.

### `after:` / `before:` — fixed windows

```
after:2026/01/01 before:2026/04/01
```

Use these when the window is a real boundary — a quarter, an event, a campaign — rather than a rolling period.

### `category:` — Gmail's own sorting

```
category:primary
category:promotions
```

Options are `primary`, `social`, `promotions`, `updates` and `forums`. `category:primary` is a blunt but surprisingly effective way to strip newsletters and automated mail out of a broad search.

---

## Supporting operators

| Operator | Matches | Note |
|---|---|---|
| `subject:` | Words in the subject line only | A bare keyword searches subject *and* body |
| `has:attachment` | Messages with any attachment | Good proxy for substantive threads |
| `filename:pdf` | Attachments by name or extension | `filename:resume` for recruiting |
| `cc:me` / `bcc:me` | Messages you were copied on | Finds threads you were looped into |
| `larger:1M` / `smaller:10k` | Message size | Large messages usually mean real documents |
| `is:unread` / `is:read` | Read state | Rarely useful for list-building |
| `in:anywhere` | Includes Spam and Trash | Almost always the wrong choice here |

---

## Combining them

Operators are ANDed by default. Space-separated terms all have to match:

```
label:clients newer_than:6m has:attachment
```

`OR` (capitals) and parentheses give you alternatives:

```
(from:@acme.com OR from:@globex.com) newer_than:1y
```

A leading `-` excludes:

```
label:inbox newer_than:3m -category:promotions -from:@yourcompany.com
```

That last one — excluding your own domain — is worth building into every query you write. Without it, a large share of any contact export is your own colleagues.

---

## Four queries that produce usable lists

**Everyone at a company you have dealt with this year**
```
from:@acme.com OR to:@acme.com newer_than:1y
```

**People who replied to a campaign or announcement**
```
to:announce@yourcompany.com newer_than:3m -from:@yourcompany.com
```

**Candidates who sent a CV**
```
has:attachment filename:resume newer_than:6m
```

**Active client threads, excluding automated mail**
```
label:clients newer_than:6m category:primary -from:noreply
```

---

## Testing before you export

Run the query in Gmail and **read the result count**.

This is the step that separates a list from a mess. If the count is in the thousands, the query is too loose — add a `newer_than:`, a `label:`, or an exclusion until the number resembles something you would actually work through. If it is zero, check for a mistyped label; Gmail fails silently on labels that do not exist.

Scroll the first page of results too. If the messages surprise you, the query is describing something other than what you meant.

---

## Turning the query into a list of addresses

Gmail will show you the messages. It will not give you the addresses inside them — there is no export button for that, and Google Takeout returns an `.mbox` archive rather than a list. ([The full comparison is here.](/blog/export-email-addresses-from-gmail-to-spreadsheet))

[Contact Extractor](/google-workspace/contact-extractor) takes the query you just tested and writes the email addresses - and the names attached to them - into a Google Sheet, deduplicated. The filters map directly onto the operators above — Gmail label, From, To, Subject, after/before dates, with the rest available under **Advanced Options** — and a **Verify** button opens the assembled query back in Gmail so you can confirm the scope matches what you tested.

You also choose which fields to read from: To, From, CC, BCC, Reply-to, subject line or message body. Operators define *which messages*; the field selection defines *which contacts within them*. Both matter.

---

## Related reading

- [How to Export Email Addresses from Gmail to a Spreadsheet](/blog/export-email-addresses-from-gmail-to-spreadsheet)
- [Advanced search options in Contact Extractor](/docs/contact-extractor/power-user-tip/advanced-search-options)
- [Filter criteria reference](/docs/contact-extractor/using-contact-extractor/filter-criteria)
