Asked by:
EWS - Filter Retrieving Unread Email Not Working

Question
-
Exchange Server Version is 2010
findResults.Items count is equal to all messages in the folder .
EDIT - turns out this is only a problem when filtering unread emails from a public folder - Is there any known workaround for this?
SearchFilter.IsEqualTo searchFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false ); int iMax = 2147483647; // Create a view with a page size of number used here. ItemView view = new ItemView(iMax); // Set the traversal to shallow. (Shallow is the default option; other options are Associated and SoftDeleted.) view.Traversal = ItemTraversal.Shallow; // Send the request to search the Inbox and get the results. FindItemsResults<Item> findResults = service.FindItems(LiveChatFolder.Id, SearchFilter, view); service.LoadPropertiesForItems(findResults.Items, new PropertySet(ItemSchema.DateTimeSent, EmailMessageSchema.Sender));
I am coding in vb, so here the original code
Dim searchFilter As New SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, False ) Dim iMax As Integer = 2147483647 ' Create a view with a page size of number used here. Dim view As New ItemView(iMax) ' Set the traversal to shallow. (Shallow is the default option; other options are Associated and SoftDeleted.) view.Traversal = ItemTraversal.Shallow ' Send the request to search the Inbox and get the results. Dim findResults As FindItemsResults(Of Item) = service.FindItems(LiveChatFolder.Id, SearchFilter, view) service.LoadPropertiesForItems(findResults.Items, New PropertySet(ItemSchema.DateTimeSent, EmailMessageSchema.Sender))
- Edited by jriggs_work Monday, December 13, 2010 2:51 PM added server version
Thursday, December 9, 2010 2:58 PM
All replies
-
Hi,
Have you tried to compare with 0 ?
IsRead is computed from PR_MESSAGE_FLAGS attribute (bitmask property), maybe SearchFilter.ExcludesBitmask would be a solution.
Regards,
Désiré GOVIN, Refresh IT SolutionsThursday, December 9, 2010 3:35 PM -
It does nothing. In addition I have double checked that the filter is working - for instance using
Dim searchFilter As New SearchFilter.ContainsSubstring(EmailMessageSchema.Subject, "Re:")
works, so its probably something to do with the filter syntax.
Also i have noticed that searchfilter.propertydefinition.version = "Exchange2007_SP1" even though our server is 2010 and I declare the service as such:
Dim service As ExchangeService = New ExchangeService(ExchangeVersion.Exchange2010)
Looks like I cant change that searchfilter property value though
Thursday, December 9, 2010 3:56 PM -
Sorry, I dont understand how I would use bitmask - can you expand a little bit?Thursday, December 9, 2010 4:08 PM
-
Bump - Do MSFT employees still monitor this forum? This seems to be a fairly large (and easily reproduced) bug.
If not, and there is a problem with my code, I would love to know what I'm doing wrong, thanks-
Monday, December 13, 2010 2:49 PM