我有这个简单的代码片段,我尝试从特定邮箱中获取文件夹
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
ExchangeService service = new ExchangeService();
service.Credentials = new WebCredentials("ADMIN_USER@corp.contoso.com", "********");
Mailbox mb = new Mailbox("chris@corp.contoso.com");
FolderId fid = new FolderId(WellKnownFolderName.MsgFolderRoot, mb);
// Set the URL.
service.Url = new Uri("https://<exchange>/EWS/Exchange.asmx");
var findResults = service.FindFolders(
fid,
new FolderView(int.MaxValue) { Traversal = FolderTraversal.Deep }
);
foreach(var result in findResults)
{
//result.Load();
Console.WriteLine(result.DisplayName);
}
之前还可以,今天早上开始报这个错误
Microsoft.Exchange.WebServices.Data.ServiceRequestException:请求失败。远程服务器返回错误:(413)请求实体太大。---> System.Net.WebException:远程服务器返回错误:(413)请求实体太大。
我尝试了不同的方法来解决它 - 主要是通过增加请求实体大小限制,但它没有帮助。我想代码没问题,但需要调整 VM 或 Exchange 配置。请指教如何解决,谢谢。