EWS The Autodiscover service couldn't be located
<p>I'm using C# EWS (ExchangeWebServices).<br>
I have ExchangeServer i.e with the following IP: 10.81.5.1.<br>
Now, I'm trying to access to ExchangeServer like the follow:<br></p>

<pre><code> ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);

 service.Credentials = new WebCredentials("myuser", "mypassword", "10.81.5.1");
 service.TraceEnabled = true;
 service.TraceFlags = TraceFlags.All;
 service.AutodiscoverUrl("myuser@mydomain.local", RedirectionUrlValidationCallback);//Throw an exception
</code></pre>

<p>And I got the following exception:<br></p>

<blockquote>
  <p>The Autodiscover service couldn't be located.</p>
</blockquote>

<p>How i know my ExchangeServer domain?</p>

<p>When I'm changed the following <strong>(and run the code inside the ExchangeServer machine)</strong><br></p>

<pre><code>service.Credentials = new WebCredentials("myuser", "mypassword");
</code></pre>

<p>Meaning the domain is the localhost i'm success to run my code without exception.

<p>What is the mistake at my code?</p>

<p>What i need to write instead "10.81.5.1" if I'm not running the code inside the ExchangeServer machine? How can i know my ExchangeServer "domain"?</p>

<p>Thanks.</p>