Hi, I'm using the code below to retrieve a list of items from an EWS hosted mailbox that contains 5000+ items.
It does this once a minute on a polled cycle.
On 2 occasions in the last month, it has failed to read all of the items, once stopping after a single page of 1000 items and the second time after 5 pages of 1000 items, both times giving no error at all, just an abbreviated list with an incorrect count, which has caused havoc for our synchronization logic, as the next time we look, the mails are back in the list.
It would appear to me that the PageResult.IsLastPage is reporting that it is the last page when there are more pages left, I can't see any other way out of the loop.
Rebex.Ews.dll is version 1.0.5759.2
// We must do this in pages so that we don't hit any server throttling limits on EWS
EwsMessageCollection ewsMessageCollection=new EwsMessageCollection();
int offset = 0;
int pageSize = 1000;
//EwsMessageCollection ewsMessageCollection2 = mailBoxMonitor.ExchangeWS.GetMessageList(new EwsFolderId(mailBoxMonitor.MailBoxSettings.Folder), EwsItemFields.Fast);
// get items of next page
EwsMessageCollection thisPageOfMessages =
// add this page of items to our master list, bu tonly the items that are actually messages
// we could see calendar invites and the like
foreach (EwsMessageInfo thisItem in thisPageOfMessages)
if (thisItem.MessageType == EwsMessageType.Message)
// break if this is the last page
// set next offset
offset = thisPageOfMessages.PageResult.NextOffset.Value;
offset += pageSize;
//EwsMessageCollection ewsMessageCollection = mailBoxMonitor.ExchangeWS.GetMessageList(new EwsFolderId(mailBoxMonitor.MailBoxSettings.Folder), EwsItemFields.Fast);
DateTime retrieveEnd = DateTime.UtcNow;
TimeSpan retrievalTime = retrieveEnd - retrieveStart;
infoLogMessage += "Retrieved " + ewsMessageCollection.Count.ToString() + " Unique Ids from EWS provider, total retrieval call time = " + retrievalTime.ToString() + Environment.NewLine;