我有一个程序。它连接到EWS,通过EWSID请求对特定文件夹进行更改,处理这些更改,然后继续相同的流程,直到没有剩余更改为止。问题在于,这似乎是一个无休止的循环。它可以与本地交换正常工作,但是在我们迁移到云(Office365)之后,问题就出现了。
使用以下代码:
MailProcessorResponse ret = new MailProcessorResponse();
ret.SyncState = syncState;
try
{
service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new NetworkCredential("Office365example@domain.com", "Password123");
service.Url = new Uri(@"https://outlook.office365.com/EWS/Exchange.asmx");
ChangeCollection<ItemChange> changes = service.SyncFolderItems(new FolderId(folderId), set, null, 512, SyncFolderItemsScope.NormalItems, ret.SyncState);
while (changes.MoreChangesAvailable)
{
createdOnly = changes.Where(x => x.ChangeType == ChangeType.Create);
ProcessChanges(createdOnly, ret, country);
ret.SyncState = changes.SyncState;
changes = service.SyncFolderItems(new FolderId(folderId), set, null, 512, SyncFolderItemsScope.NormalItems, ret.SyncState);
}
createdOnly = changes.Where(x => x.ChangeType == ChangeType.Create);
ProcessChanges(createdOnly, ret, country);
ret.SyncState = changes.SyncState;
}
}
catch (Exception ex)
{
ret.Exceptions.Add(ex);
Libs.Logger.Write(ex);
}
return ret;
}
参数syncState输入到方法中。 -上次更新是在我们迁移到云之前。
参数folderID是EWS文件夹ID。它也输入到方法中。
有人有什么想法吗,什么是错的或我想念的是什么?