Blog/ Gmail how-tos

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

Nafiul HasanNafiul Hasan· 9 min read
Gmail search bar next to a PDF icon, illustrating a search by attachment filename versus a search for text inside the file

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
  1. 01How to search Gmail for emails with attachments
  2. 02Narrow the results in four steps
  3. 03How to search for PDF attachments in Gmail
  4. 04Why an attachment search can come back empty
  5. 05Can Gmail search the text inside attachments?
  6. 06What to do when the phrase is inside the file
  7. 07Where AI Emaily fits

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 wantType thisWhat it matches
Any email with a filehas:attachmentMessages that have an attachment
Only PDFshas:attachment filename:pdfMessages with an attachment of that file type
A specific file namefilename:contract.pdfMessages with an attachment of that name
Spreadsheetshas:attachment filename:xlsxMessages with an Excel attachment
Big files onlyhas:attachment larger:5MMessages with an attachment over that size
From one person, recenthas:attachment from:alice after:2026/01/01Attachments from a sender after a date
Drive fileshas:driveMessages that include Drive files
Google Docs, Sheets, Slideshas:document, has:spreadsheet, has:presentationMessages 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. 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. 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. 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. 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 forWhat Google documentsWhat to do
Whether a file is attachedhas:attachment is documentedUse it
File name or file typefilename: is documentedUse it
A word inside a PDF or Word fileNot stated on the operator help pageRun the test below
Text inside a scanned image or photoNot stated on the operator help pageTest it separately
Text inside a file stored in DriveDrive search can look at text within files, per Drive HelpSearch 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. 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. 2

    Email it to yourself

    Send the file to your own Gmail address with an unrelated subject and a short, ordinary message.

  3. 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. 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

Google Drive's help says Drive search can match text within files. That is Drive search, not Gmail search, and it applies to files that are stored in Drive. An attachment that lives only in an email is not automatically in Drive.

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.
Abstract illustration of one line splitting into several paths, standing for the choice between searching Gmail by file name and searching somewhere else for text inside a file
Operators reach the email through its filename and type. Text inside a file may need Drive or your computer's file search.

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

Nafiul Hasan

Written by

Nafiul Hasan

Nafiul 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.

EntrepreneurAI Automation System BuilderAI EnthusiastBuilds AI Enterprise Solutions10+ years experience
More from Nafiul
Ready when you are

Find email by meaning, not just filename

AI Emaily's semantic search finds the thread you are thinking of even when you cannot remember the sender, subject or filename. 7-day free trial on Pro or Autopilot.

  • 7-day free trial
  • Cancel anytime
  • Every provider