Skip to content

Filter on multiple possible senders #1769

Answered by jstedfast
IT-VBFK asked this question in Q&A
Discussion options

You must be logged in to vote

I would do something more like this:

string[] permittedSenders = // passed in via .env
var query = SearchQuery.FromContains(permittedSenders[0]);

for (int i = 1; i < permittedSenders.Count; i++)
{
    query = query.Or(SearchQuery.FromContains(permittedSenders[i]))
}
client.Inbox.Search(query.And(SearchQuery.NotSeen))

Keep in mind that new SearchQuery() is saying "ALL messages" and so the query you are using right now is "(ALL messages -OR- messages from permittedSenders[0] -OR- permittedSenders[1] ...) -AND- NotSeen"

I'm not sure why you are getting the results you are getting because to me, it would make more sense that you are getting all unseen messages.

That said, the query in my exa…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@IT-VBFK
Comment options

@jstedfast
Comment options

Answer selected by IT-VBFK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants