无法使用EWS访问电子邮件帐户的收件箱:请求失败。远程服务器返回错误:(401)未经授权

时间:2013-06-03 19:21:06

标签: exchangewebservices ews-managed-api

我们正尝试使用EWS(https://mailserver.com/EWS/Exchange.asmx)访问电子邮件帐户的收件箱。但是我们不断收到以下错误:

请求失败。远程服务器返回错误:(401)未经授权。

我的源代码在这里:

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);                            
    ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain,     sslPolicyErrors) => true;
    service.Url = new Uri("https://mailserver.com/EWS/Exchange.asmx");
    service.Credentials = new WebCredentials("UserName", "Password", null);
    ItemView view = new ItemView(50);
    FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, view); 

//此行错误

0 个答案:

没有答案