我正在尝试使用Microsoft.Exchange.WebServices.dll获取Office365用户帐户电子邮件 . 但是在加载数据请求时我遇到间歇性错误 . 电子邮件的加载请求似乎被卡住或者它将引发异常 .

这是我的示例代码:

_ExchnageService.KeepAlive = true;

PropertySet objProperty = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent);

_Item.Load(objProperty ); // Some times load request didn't respond for hours which appears to be stuck. 

//And some times it thorws following exeption

Microsoft.Exchange.WebServices.Data.ServiceRequestException:请求失败 . 无法从传输连接读取数据:远程主机强制关闭现有连接 . ---> System.IO.IOException:无法从传输连接读取数据:远程主机强制关闭现有连接 . ---> System.Net.Sockets.SocketException:远程主机在System的System.Net.Sockets.Socket.Receive(Byte []缓冲区,Int32偏移量,Int32大小,SocketFlags socketFlags)强制关闭现有连接 . Net.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)---内部异常堆栈跟踪结束---在System.Net.ConnectStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)在System.IO.Compress.DeflateStream.Read(Byte []数组,Int32偏移量,Int32计数)处于Microsoft.Exchange的System.IO.Compression.GZipStream.Read(Byte []数组,Int32偏移量,Int32计数) . Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse response)中的WebServices.Data.EwsUtilities.CopyStream(Stream source,Stream target)---内部异常堆栈跟踪结束---在Microsoft.Exchange.WebServices.Data Microsoft.SExchange.WebServices.Data.SimpleServiceRequestBase.InternalExecut中的.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse响应) e()位于Microsoft.Exchange.WebServices.Data上的Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest1.Execute(),以及Microsoft.Exchange.WebServices.Data.Item上的Microsoft.Exchange.WebServices.Data.ExchangeService.InternalLoadPropertiesForItems(IEnumerable1 items,PropertySet propertySet,ServiceErrorHandling errorHandling) . 位于CDT.Office365Reader.DownloadO365Mails.RetriveO365MailValues的Microsoft.Exchange.WebServices.Data.ServiceObject.Load(PropertySet属性集)中的InternalLoad(PropertySet propertySet)(项目p_obj_Item,FolderID folderId,String p_FolderPath,ExchangeService p_ExchnageService,String p_username)

非常感谢您对此问题的任何帮助或建议 .