Gmail filters can use attachment-related search conditions, but attachments and shared links are not the same thing. Test the condition against the kinds of messages you actually receive before applying automatic actions. A search match does not establish that a file is safe to open.
Choose the appropriate attachment condition
Start with has:attachment for attachment-bearing mail. Add a sender or a supported filename condition, such as filename:pdf, when that is the actual distinction you need.
For shared Google content, inspect operators such as has:drive or has:document. A Drive link does not have to behave like a conventional attached file, and finding the sharing email does not grant access to the underlying document.
Create a visible test rule
- Run the proposed search and inspect messages that should match.
- Compare a similar message without the intended attachment type.
- Choose Create filter and apply a distinctive label.
- Keep mail in Inbox while testing harmless new deliveries.
Do not choose Delete it or automatic forwarding during an initial attachment test. A broad attachment rule can affect invoices, contracts, personal photographs, and security-related reports alike.
Check replies and file limitations
Google states that each reply must meet a filter’s criteria itself. A reply with no attachment may remain unfiltered even when an earlier message in the same conversation carried the file. Open individual messages when the thread’s label display seems inconsistent.
Filename and attachment presence are organizing clues, not malware screening. An executable can have a deceptive name, and a PDF can contain a malicious link. Preserve Gmail’s warnings and verify unexpected files with the sender through a trusted route.
If expected mail is not found, reduce the query to the sender and inspect how the file was actually delivered. Do not install a mailbox-reading attachment extractor or bypass a blocked-file warning merely to make a filter appear successful. Keep access permissions, storage cleanup, and attachment classification as separate decisions.
Browse Gmail & Google Account help
References
Reviewed against the linked product guidance, standards, and identified vendor or public-authority guidance on October 29, 2026. Available options and screen labels can vary by account, device, region, and organization policy.