NekoUnderscore
NekoUnderscore

Reputation: 153

Filter EWS mailbox by recipient address using exchangelib

I'm writing a monitoring solution using python3 with exchangelib and trying to count messages in our team's mailbox. One of the criteria: recipient list must contain specific email address.

When i use filter() with author or subject arguments script is working fine and return correct results.

But when i tried to filter by to_recipients or to_recipients__contains (which is list-type field), script throws an exception:

ValueError: EWS does not support filtering on field 'to_recipients'

Is there a way to filter mailbox by recipient email_address, avoiding to fetch all messages and than filtering it on the client side?

Upvotes: 4

Views: 1407

Answers (1)

Erik Cederstrand
Erik Cederstrand

Reputation: 10220

[exchangelib maintainer here]

I don't think there is. You could try to flip the is_searchable flag on that field and search anyway, but I never could get filtering to work in my tests. I can't remember if it throws server errors, returns all items anyway, or returns an empty list.

I'm happy to accept patches it you do find a solution.

Upvotes: 1

Related Questions