首页 > 解决方案 > Microsoft.graph API 无法读取电子邮件

问题描述

我正在使用Microsoft.graph API从 office365 帐户读取电子邮件。当我同时阅读多个帐户时,我遇到了一个问题。对于某些帐户,数据会被跳过。

例如,如果 xyx@microsoft.com 帐户的“收件箱”文件夹中包含大约90k封电子邮件,那么在从 API 读取电子邮件时,我们只会收到大约40k封电子邮件。当我们放置多个帐户进行迁移时,会观察到此结果。对于单帐户迁移,它可以正常工作。

ExcMsg  : **Too many concurrent connections opened., Cannot open mailbox.** 
Stack: 
    at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary(),    
    at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.<ExecuteAsync>d__6.MoveNext(),
 --- End of stack trace from previous location where exception was thrown ---,
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(),
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task),
    at Microsoft.Exchange.WebServices.Data.ExchangeService.<BindToItem>d__71.MoveNext(), 
--- End of stack trace from previous location where exception was thrown ---,
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(),
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task),
    at Microsoft.Exchange.WebServices.Data.ExchangeService.<BindToItem>d__72`1.MoveNext()
if (MessagesList != null && MessagesList.NextPageRequest != null)
    MessagesListRequest = MessagesList.NextPageRequest;

MessagesList = MicrosoftHelper.InvokeApiCall(() =>
    {
         return MessagesListRequest.GetAsync().Result;
    }, this.Context);

where MessagesList  is IMailFolderMessagesCollectionPage 

标签: c#microsoft-graph-api

解决方案


推荐阅读