[Exchange-Online] [EWS] [C#] Unable to autodiscover endpoint using EWS for Exchange Online email RRS feed

  • Question

  • Few hours ago I signed up for a trial to test the waters. First thing I did was try and play with EWS using the C# API. The issue I'm running into is that I'm unable to find the correct end point using the autodiscover service. I have checked the remote connectivity Analyzer provided by Microsoft, which is successful at autodiscovering my email settings.

    The code I'm using is as follows:

    var exchangeService = new ExchangeService(ExchangeVersion.Exchange2010_SP2)
    Credentials = new WebCredentials(EMAIL, PASSWORD)

    Lastly, I had issues connecting from Outlook 2010 and had to set the Exchange proxy settings where I found instructions how to do so here. I'm not sure how to do that with the EWS API. I tried using the `WebProxy` property but that didn't change anything.

    Why can't I autodiscover my endpoint? Note that I am not using a custom domain.

    Thank you.

    • Edited by MikeC123-- Sunday, September 16, 2012 3:23 PM
    Sunday, September 16, 2012 3:18 PM


  • If you have only just created your account then you do need to allow time for DNS propagation, the Exchange Proxy setting refers to the OutlookAnywhere setting so aren't applicable to EWS. You would only need to worry about a WebProxy if your access to the Internet is via a proxy server. With ExchangeOnline you can use the endpoint directly https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc which will be the quickest way to discover the actual CAS Endpoint to use eg.

                NetworkCredential creds = new NetworkCredential("user@domain.onmicrosoft.com", "password");
                AutodiscoverService adAutoDiscoverService = new AutodiscoverService(ExchangeVersion.Exchange2010_SP2);
                adAutoDiscoverService.Url = new Uri("https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc");
                adAutoDiscoverService.Credentials = creds;
                adAutoDiscoverService.EnableScpLookup = false;
                adAutoDiscoverService.RedirectionUrlValidationCallback = adAutoDiscoCallBack;
                adAutoDiscoverService.PreAuthenticate = true;
                adAutoDiscoverService.TraceEnabled = true;
                GetUserSettingsResponse adResponse = adAutoDiscoverService.GetUserSettings("user@domain.onmicrosoft.com", (new UserSettingName[1] { UserSettingName.ExternalEwsUrl }));
                if (adResponse.Settings.Count >= 1)
                    String exClientURL = (String)adResponse.Settings[UserSettingName.ExternalEwsUrl];
                    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
                    service.Url = new Uri(exClientURL);
                    service.Credentials = creds;
                    Folder Inbox = Folder.Bind(service,WellKnownFolderName.Inbox);

    • Marked as answer by MikeC123-- Monday, September 17, 2012 7:59 PM
    Monday, September 17, 2012 6:23 AM