Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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("[email protected]",
    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 = "[email protected]";
service.AutodiscoverUrl(userName,
    delegate
    {
    return true;
    });

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

Sanjay

like image 422
Sanjay Zalke Avatar asked Oct 21 '11 14:10

Sanjay Zalke


2 Answers

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.

like image 120
Henning Krause Avatar answered Oct 29 '22 18:10

Henning Krause


I realize this post is a few years old, but I'm offering an additional solution simply for the sake of documentation.

Another possible cause of this behavior is the client is attempting to force a TLS 1.2 connection when the EWS server is supporting only TLS 1.0. I was about to surrender investigating this very behavior - an EWS app worked on one box, and the same app failed on a different box (going to the same mailbox) - and the problem was one machine could negotiate TLS 1.0, which worked, while the other could do TLS 1.2 only, which failed. Enabling client TLS 1.0 outbound connections in the registry (HKLM\System\CCS\Services\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client, DWORD value 'Enabled' set to 0x1 fixed the problem. No reboot required.

like image 38
David W Avatar answered Oct 29 '22 17:10

David W