I’m developing client application, which connects to a mailbox then reads/parses messages and updates client database. The company uses Office 365. I’m using Managed APIs :
var _service =newExchangeService(ExchangeVersion.Exchange2010_SP1);
_service.TraceEnabled = true;
_service.Credentials = new System.Net.NetworkCredential("user_id","user_pwd");
AutodiscoverService ads =newAutodiscoverService();
ads.EnableScpLookup = false;
ads.RedirectionUrlValidationCallback = delegate {returntrue; };
GetUserSettingsResponse grResp = ads.GetUserSettings("user_id@domain_name.com",UserSettingName.InternalEwsUrl);
Uri casURI =newUri(grResp.Settings[UserSettingName.ExternalEwsUrl].ToString());
_service.Url = casURI;
Line starting “ads.GetUserSettings..” gives the error “The remote server returned an error: (401) Unauthorized…” even though I logged as the Exchange Admin...