I am using Auto discover service Url for a specified e-mail address.
ExchangeService Service = new ExchangeService(ExchangeVersion.Exchange2010);
Service.Cr
I have hit this and a trace shows that after using the proxy to access 365 it starts a DNS lookup for an SVC record. This lookup goes to internal DNS and not the proxy, our internal DNS does not resolve external DNS entries, that is why we have proxy servers. Not yet found out why it is doing a DNS lookup rather than using the proxy servers, but that is what is causing our version of this problem
Let me point out that if you are trying to access Office 365 then the web credentials really are of the form WebCredentials(strUsername, strPassword); with strUsername being the email address of the account you are trying to access.
I was getting this error and it turned out someone had changed the password on the account without informing me! What an odd error to get when it's just a bad password!
I'd recommend that you verify that autodiscover is actually setup in DNS. The following article explains how to set it up in more detail and it also gives you information on how to test it with the Microsoft Remote Connectivity Analyzer.http://www.petri.co.il/autodiscover-configuration-exchange-2010.htm
For the record of completeness:
We encountered a service suddenly stopping with this particular error. As the service had been running unattended for months, using EWS to monitor a mailbox, it turned out that the password was expired. This caused the AutoDiscovery to fail with the very same exception:
The Autodiscover service couldn't be located
Updating the Exchange user's password in the AD and checking its Password Never Expires
property solved the problem for us.
Faced this issue for specific user. After checking I found that user has enabled two factor authentication and using his primary password for connection. Solved by generating app specific password and connecting with it. Disabling two factor also worked, but it will take some time to reflect. Not sure why exchange gave "The Autodiscover service couldn't be located." instead of "Unauthorised".
try to use this:
Service.Credentials = new WebCredentials("john", "12345678", "MYDOMAIN");
NOT this one
Service.Credentials = new WebCredentials("john@mail.com", "12345678", "MYDOMAIN");
notice the username is 'john'
NOT 'john@mail.com'
,It blocked me for quite a few hours for using the second one....