Outlook can find emails with one or more attachments by specifying the “Has Attachments” option.
But how can I search for a specific type of attached file?
e.g. search for emails having .docx, .pdf, .xlsx or .zip files etc.
Is it also possible to only search for text within an attachment and not within the message body?
Searching for a specific type of file isn’t directly supported by a search option, but you can do this by typing the search command
A short but effective search command.
Note: You can also use this query command in the Search field of the Start Menu or Explorer to limit your search to specific file types.
Search for multiple attachment types in one search
If you want to search for messages which contain at least 2 specific type of file attachments, you’ll have to enclose your search in round brackets after you specify the
ext: search command:
If you want to search for messages which contain at least one of the file types, you must use the
OR statement (case sensitive!):
ext:(docx OR pdf)
ext:(xlsx OR zip)
ext:(docx OR pdf OR xlsx OR zip)
Exclude attachment types
If you want to exclude a specific file type from your search, you can use the NOT statement (case sensitive!). This can be useful when you want to search for doc files specifically and not also include docx files in your results.
ext:(doc NOT docx)
ext:(xls NOT xlsx)
To search for all attachments except for some specific types, you must also include the command
hasattachments:yes or you’ll also get all messages without attachments returned:
ext:(NOT docx) hasattachments:yes
ext:(NOT docx NOT pdf NOT xlsx) hasattachments:yes
Search in attachment and message body text
You can combine this with a regular search term to look in the message itself as well as in the attachment:
ext:docx your search text
ext:(docx OR pdf) your search text
Search in attachment text only
If you only want to search within the attachment, you’ll have to specify the
attachment: field as well:
ext:pdf attachment:(search with multiple words)
Search for file types inside zip-files
Sadly, there is no specific search command to also include zip-files which contain a specific file type in the results. For instance, to return all doc-files and all zip-files which contain a doc-file.
You can achieve a close approximation by using an
OR statement which searches within the zip-file for a specific word in the contained files (which includes the file extension);
ext:(docx) OR (ext:zip attachment:docx)
ext:(pdf) OR (ext:zip attachment:pdf)
As said, this won’t be an exact search as it will also return messages with zip-files attached which have files containing the word
Note: For more about using Instant Search commands in Outlook see the guide; Instant Search query commands reference