My company just moved some mailboxes into O365. This has had the unfortunate effect of breaking an application created using EWS. When attempting to call out to AutodiscoverUrl(), I am met with an error.
'The Autodiscover service couldn't be located.'
Code:
service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl(mailbox, RedirectionCallback);
private bool RedirectionCallback(string url)
{
return true;
}
I have also tried setting the URL to the following
service.Url = new Uri("https://autodiscover.MYDOMAIN.com/autodiscover/autodiscover.xml");
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
Neither of those have resolved the issue. Does anyone know where to go from here?
url is https://outlook.office365.com/EWS/Exchange.asmx
public ExchangeService Connect()
{
var lastExchangeVersion = Enum.GetValues(typeof(ExchangeVersion)).Cast<ExchangeVersion>().ToList().Last();
var service = new ExchangeService(lastExchangeVersion)
{
Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"),
Credentials = new NetworkCredential(_cloudEmail, _cloudPassword)
};
return service;
}
public SecureString ConvertStringToSecure(string password)
{
if (string.IsNullOrWhiteSpace(password)) return null;
var result = new SecureString();
foreach (char c in password) result.AppendChar(c);
return result;
}