Search code examples
google-apps-scriptgmailgmail-api

How to filter messages that do NOT have attachments using GMail query language?


How do I filter out Gmail messages that DO NOT have attachments?

Here is the documentation I'm trying to follow.

I can see that in order to include messages with attachments, I use the following query:

has:attachment

However, I do not see a way to do the inverse. I seek something like:

!has:attachment

What am I missing?


Solution

  • Summary from comments

    Both of the following work:

    !has:attachment
    

    and

    -has:attachment