Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Autodiscover service couldn't be located' when trying to access Exchange 2010 account with EWS MANAGED API

I am using Auto discover service Url for a specified e-mail address.

ExchangeService Service = new ExchangeService(ExchangeVersion.Exchange2010); Service.Credentials = new WebCredentials("[email protected]", "Password"); Service.AutodiscoverUrl("[email protected]"); 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?

like image 419
user1891567 Avatar asked Feb 25 '13 10:02

user1891567


1 Answers

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:

  1. The version you specify in new ExchangeService() matches server's
  2. 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("[email protected]"); 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 
like image 90
Alex Avatar answered Sep 23 '22 01:09

Alex