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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With