How to Search Gmail for Attachments (and What About the Text Inside Them)

The short answer
To search Gmail for emails with attachments, type has:attachment in the search box, then narrow it with filename:pdf for a file type or filename:contract for a name. These operators match whether a file is attached, its type and its name. Google's help page does not document searching text inside attachments, so test it with a phrase you know is in a file.
Search Gmail for emails with attachments using has:attachment and filename:pdf, plus what Google documents about searching text inside PDFs and Word files.
On this page
The fastest way to search Gmail for emails with attachments is to type an operator into the search box. Copy one of these lines and change the words to match your file:
- has:attachment finds any message that has a file attached.
- has:attachment filename:pdf finds messages with a PDF attached.
- filename:contract.pdf finds messages with an attachment named contract.pdf.
Those three cover most searches. The second question people ask, whether Gmail can find a word that is written inside a PDF or Word file, has a less tidy answer, and it gets its own section further down.
How to search Gmail for emails with attachments#
Gmail's own operator list describes has:attachment as emails with attachments, and filename: as a way to find emails that have attachments with a certain name or file type. Everything in the table below comes from that list. Type it into the search bar at the top of Gmail and press Enter.
| What you want | Type this | What it matches |
|---|---|---|
| Any email with a file | has:attachment | Messages that have an attachment |
| Only PDFs | has:attachment filename:pdf | Messages with an attachment of that file type |
| A specific file name | filename:contract.pdf | Messages with an attachment of that name |
| Spreadsheets | has:attachment filename:xlsx | Messages with an Excel attachment |
| Big files only | has:attachment larger:5M | Messages with an attachment over that size |
| From one person, recent | has:attachment from:alice after:2026/01/01 | Attachments from a sender after a date |
| Drive files | has:drive | Messages that include Drive files |
| Google Docs, Sheets, Slides | has:document, has:spreadsheet, has:presentation | Messages that include that kind of Google file |
If you are cleaning up storage rather than hunting for one file, the size operators have their own guide: find large attachments in Gmail. For the full operator list, see the Gmail search operators guide.
In the Gmail app you can type the same operators into the search box. What the app shows can differ a little from the web version, so if a result looks incomplete, repeat the search in a browser.
Narrow the results in four steps#
A bare has:attachment search returns everything with a file. These four additions shrink it fast, in the order most people remember details.
- 1
Add a file type
Put filename: and an extension after has:attachment: has:attachment filename:pdf for PDFs, filename:docx for Word, filename:xlsx for spreadsheets, filename:zip for archives. The extension alone is enough.
- 2
Add part of the file name
If you remember a word from the name, use it: filename:contract. Gmail describes filename: as matching a name or a file type, so a partial name is worth trying before the full one.
- 3
Add the sender
from:[email protected] has:attachment filename:pdf finds PDFs from that address. Sender plus file type is often the quickest way to retrieve a document someone emailed you.
- 4
Add a date window
Use after: and before: with dates written as year/month/day, for example after:2025/10/01 before:2026/01/01, or newer_than:30d for the past month.
How to search for PDF attachments in Gmail#
To search PDF attachments in Gmail, start with has:attachment filename:pdf. Add a word to look for a particular PDF: has:attachment filename:pdf invoice. A plain word is searched the way Gmail searches any other term, so it will match the email's subject, body or the file name. Whether it can also match text inside the PDF is the question the next section is about.
To find one specific PDF, use its name or a piece of it: filename:invoice finds files with invoice in the name, and filename:report.docx finds a Word file called report. To search by attachment type without caring about the name, filename:xlsx or filename:pptx does the job.
Why an attachment search can come back empty#
If you are sure the file exists and the search finds nothing, check these before assuming the email is gone.
- The file may be a Drive link rather than an attachment: try has:drive, has:document, has:spreadsheet or has:presentation as well as has:attachment.
- The extension may differ from what you typed: try filename:jpg and filename:jpeg, or filename:doc and filename:docx.
- The message may be in Spam or Trash: add in:anywhere to search all of Gmail, including Spam and Trash.
- Your date window may be too tight: remove after: and before: first, then add them back.
Can Gmail search the text inside attachments?#
Google's operator help page does not say. It describes filename: as matching a name or file type, and it never states that Gmail searches the words written inside a PDF, Word or Excel file. We would rather not guess in either direction.
Published reports disagree. In October 2012 the blog Google Operating System wrote that Gmail had added support for searching inside attachments, and said the author had tried it on PDF, Word and PowerPoint files. More recent guides, including an earlier version of this one, say the opposite without citing a Google document. So treat it as unconfirmed for your account, and test it in two minutes.
| What you search for | What Google documents | What to do |
|---|---|---|
| Whether a file is attached | has:attachment is documented | Use it |
| File name or file type | filename: is documented | Use it |
| A word inside a PDF or Word file | Not stated on the operator help page | Run the test below |
| Text inside a scanned image or photo | Not stated on the operator help page | Test it separately |
| Text inside a file stored in Drive | Drive search can look at text within files, per Drive Help | Search at drive.google.com |
Here is a quick test you can run yourself. Run it with the kind of file you actually care about, because results can differ between PDFs, Word files and scanned pages.
- 1
Pick a file with an unusual word
Take a PDF or Word document and put a made-up word in the body of the file only, for example zqxvlorbit. Do not put it in the file name or in the email text.
- 2
Email it to yourself
Send the file to your own Gmail address with an unrelated subject and a short, ordinary message.
- 3
Search for the made-up word
After a few minutes, search for the word. If the message appears, Gmail is matching text inside that kind of file. If it does not, it is not matching it, or has not indexed it yet. Try again later before you decide.
- 4
Repeat for other file types
Do the same with a Word file, a spreadsheet and, if you work with scans, an image-only PDF. Scanned pages contain no selectable text, so they are the case most likely to behave differently.
Drive search is a different search
What to do when the phrase is inside the file#
If your test shows Gmail does not match the words inside the file, these routes get you to the email anyway, from quickest to broadest.
- Work backward from the email: the sender, a rough date, a word in the subject or the file name are all searchable. Use the operators above to reach the thread, then open the attachment.
- Search Google Drive: if the file is in Drive, search there. Drive's help describes searching for text within a file.
- Use your computer's file search: if you downloaded the file, your operating system may index text inside documents, depending on the file type and your settings. Search the folder where you saved it.
- Save important attachments to Drive when they arrive: for contracts and proposals you will need again, use Save to Drive from the attachment preview so they can be searched there later.

Where AI Emaily fits#
We build AI Emaily, so here is its honest limit first: its search does not look inside attachments today. Search runs on its own keyword plus semantic index over synced mail (the first sync covers about the last 60 days). It covers subjects, body text and sender and recipient names, and attached file names are indexed. Searching attachment content is on the roadmap, not live.
What it can do is describe the email the way you remember it. Semantic search matches by meaning, so a thread about the contract the lawyer sent before the deadline can surface even when none of those words are in the subject. When you already have the thread open, an AI assistant connected through AI Emaily's MCP server can read the text of a PDF or Word attachment on request, for documents with selectable text. Scanned image-only PDFs cannot be read that way.
AI Emaily has a 7-day free trial on Pro or Autopilot. See the pricing page for what each plan includes, or start from the homepage.
Frequently asked
See it in AI Emaily
Keep reading
Sources

Written by
Nafiul HasanNafiul Hasan is an entrepreneur and AI automation system builder with 10+ years of experience turning messy, manual workflows into reliable automated systems. He designs and ships AI enterprise solutions end-to-end — the agent logic, the data plumbing, and the product people actually use — and founded AI Emaily to give busy professionals their attention back. He writes here from the builder's seat: what works, what breaks, and how to put AI to work without giving up control.