I am using Google.Apis.Gmail.v1 within a c# project and I am getting a list of messages via the Users.Messages.List(...) function. Before executing the call to Google, I also set the Q property to query the search. However, the query is not functioning as I expect, as it seems to ignore all label references.
Reading through Google's reference docs, I expect to be able to use any query string that Gmail UI accepts.
I have used the following two Q property strings.
request.Q = "from:([email protected]) subject:(Specific Subject Search has * in it) has:nouserlabels has:attachment";
request.Q = "from:([email protected]) subject:(Specific Subject Search has * in it) -label:specific-label has:attachment";
I have also tried using the labelId for the specific label and it does not work either.
These query strings return all the messages that satisfy only the from: and has:attachment properties. It does not seem to matter what I try, regarding the labels (has:nouserlabels or -label:specific-label or -label:labelId).
I can use these queries directly within the Gmail UI and it returns results as expected.
Does anybody have success filtering messages with labels? I am trying to exclude a certain label.