Following is my code.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.TraceEnabled = true; service.Credentials = new WebCredentials("xx@xx.com", "xxxx123"); service.Url = new Uri("https://mail.xxxxxx.com/EWS/Exchange.asmx"); FolderView v = new FolderView(5); ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback; service.FindFolders(WellKnownFolderName.Inbox, v); //Error on above line.
I tried changing the code line as below and I get another Error ....
service.Credentials = new NetworkCredential("xx@xx.com", "xx","xxxxxxxx");
"The remote server returned an error: (401) Unauthorized."
How do i resolve. and what is difference between NetworkCredential and WebCredentials ?
This is Resolved.
I figure out that the problem was in code line
service.Credentials = new NetworkCredential("xx@xx.com", "xx","xxxxxxxx");
Instead of xx@xx.com it should be just username 'xx'. That Solved.
Phew!!
Regards