I am using C # EWS (ExchangeWebServices).
I have an ExchangeServer ie with the following IP: 10.81.5.1.
Now I'm trying to access ExchangeServer, as shown below:
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);
And I got the following exception:
Could not find the Autodiscover service.
How do I know my ExchangeServer domain?
When I changed the following (and ran the code inside the ExchangeServer machine)
service.Credentials = new WebCredentials("myuser", "mypassword");
The domain value is the local host. I successfully execute my code without exception.
What is the error in my code?
What do I need to write instead of "10.81.5.1" if I do not run the code inside the ExchangeServer machine? How can I find out my ExchangeServer domain?
Thank.