Search code examples
exchangewebservicesoffice365

The Autodiscover service couldn't be located


I have code to send email using Exchange Web Services (EWS 1.1 API). There is no exception if I use the hardcoded parameter values, like:

service.AutodiscoverUrl("me@mydomain.com",
    delegate
    {
    return true;
    });

But If I try to use a variable then I am getting error while discovering URL, "The Autodiscover service couldn't be located".

string userName = "me@mydomain.com";
service.AutodiscoverUrl(userName,
    delegate
    {
    return true;
    });

Is there any way to use variables with autodiscoverurl method? What am I doing wrong?

Sanjay


Solution

  • It's very unlikely that this is causing the problem. Typically, if AutoDiscover fails, it's because of invalid credentials or network connectivity issues.

    Enable tracing on the ExchangeService instance (MSDN article) to see what is going on.