Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

How to use EWS SearchFilter to only find emails with attachments through service.finditems

$
0
0

Through EWS, I'm able to locate a folder and walk its emails while checking each one for attachments.  But, it would be faster if I can get the finditems method to ONLY return emails with attachments so I don't have to check each one as I walk through them.

I've figured this is only a matter of specifying the correct SearchFilter so that only items with attachments are returned.  But, I have no idea how to design such a filter.  I've tried the following:

SearchFilter.IsEqualTo sfEmailsWithAttachments = new SearchFilter.IsEqualTo();
sfEmailsWithAttachments.PropertyDefinition = EmailMessageSchema.Attachments; //field to search on
sfEmailsWithAttachments.Value = null;//value to check for
But, EWS doesn't recognize this as a valid way to use the Attachments property in a search.  I've looked everywhere on the internet and haven't been able to find an example to filter attachments in EWS.  Everyone seems to walk the returned items and check each one for attachments.  If an inbox has thousands of emails, which only a few have attachments, this can take an uneccesary long time.

Any ideas on how to restrict the search to only emails with attachments?




Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>