尝试使用EWS MANAGED API访问Exchange 2010帐户时“找不到自动发现服务" [英] 'Autodiscover service couldn't be located' when trying to access Exchange 2010 account with EWS MANAGED API
本文介绍了尝试使用EWS MANAGED API访问Exchange 2010帐户时“找不到自动发现服务"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用自动发现服务URL来指定电子邮件地址.
I am using Auto discover service Url for a specified e-mail address.
ExchangeService Service = new ExchangeService(ExchangeVersion.Exchange2010);
Service.Credentials = new WebCredentials("username@domainname.com", "Password");
Service.AutodiscoverUrl("username@domainname.com");
Folder inbox = Folder.Bind(Service, WellKnownFolderName.Inbox);
Console.WriteLine("The folder name is" + inbox.DisplayName.ToString());
如果我这样做,我会出错:
If I do like this I'm gettin an error:
找不到自动发现服务
The Autodiscover service couldn't be located
为避免此错误我该怎么做?
What I have to do to avoid this error?
推荐答案
您弄错了Service.Credentials
,请像这样使用它:
You got Service.Credentials
wrong, use it like this:
Service.Credentials = new WebCredentials(username, password, domainname);
使用域凭据,而不是电子邮件地址.
Using domain credentials, not the email address.
还要仔细检查以下内容:
Also doublecheck the following:
- 您在
new ExchangeService()
中指定的版本与服务器的 匹配
- 传递给
Service.AutodiscoverUrl();
的参数正确(需要获取数据的电子邮件地址)
- The version you specify in
new ExchangeService()
matches server's - the parameter passed to
Service.AutodiscoverUrl();
is correct (email address which data needs to be fetched)
以下对我有用(在新的控制台应用程序中):
The following works for me (in a new Console Application):
// Tweaked to match server version
ExchangeService Service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
// Dummy but realistic credentials provided below
Service.Credentials = new WebCredentials("john", "12345678", "MYDOMAIN");
Service.AutodiscoverUrl("john.smith@mydomain.it");
Folder inbox = Folder.Bind(Service, WellKnownFolderName.Inbox);
Console.WriteLine("The folder name is " + inbox.DisplayName.ToString());
//Console output follows (IT localized environment, 'Posta in arrivo' = 'Inbox')
> The folder name is Posta in arrivo
这篇关于尝试使用EWS MANAGED API访问Exchange 2010帐户时“找不到自动发现服务"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文