c# - Exchange Service FindItems API does not always find all matching messages -
i have program once every few hours synchronizes office 365 online mailbox database collection. in order pull down latest messages, i'm using exchangeservice c# api
however, every once in while, newest messages contacts not come thru. when search messages via outlook, shows them no problem. but, c# code searches messages email id not find them.
am missing criteria in search strings? or perhaps there caching going on - how disable it?
i have 10-20 messages per search result (this not thousands)
here's relevant code:
foreach (var item in customer.contacts) { search.add(new searchfilter.containssubstring(emailmessageschema.torecipients, item.email)); search.add(new searchfilter.containssubstring(emailmessageschema.ccrecipients, item.email)); search.add(new searchfilter.containssubstring(emailmessageschema.from, item.email)); search.add(new searchfilter.containssubstring(emailmessageschema.sender, item.email)); search.add(new searchfilter.containssubstring(itemschema.displayto, item.email)); search.add(new searchfilter.containssubstring(itemschema.body, item.email)); } var filter = new searchfilter.searchfiltercollection(logicaloperator.or, search.toarray()); var inboxcollection = _exchangeclient.finditems(wellknownfoldername.inbox, filter, new itemview(1000) {propertyset = propertyset.firstclassproperties});
that searchfilter because of number of containssubstring searches not going efficient search backend server do. suggest query , filter more of results @ client side try use such complex query. eg use aqs search on participants property , body https://msdn.microsoft.com/en-us/library/office/dn579420(v=exchg.150).aspx same thing query , use indexes faster.
why seeing behaviour reporting because of inefficient search , way searching works, when try search 1 using temporary restriction on folder in question little old explains quite https://technet.microsoft.com/en-us/library/cc535025(exchg.80).aspx .
cheers glen
Comments
Post a Comment