Skip to content

Instantly share code, notes, and snippets.

@svrooij
Last active August 29, 2015 14:18
Show Gist options
  • Save svrooij/2be856f613cc365263c0 to your computer and use it in GitHub Desktop.
Save svrooij/2be856f613cc365263c0 to your computer and use it in GitHub Desktop.
Resolve exchange alias to SMTP-address
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri("https://serv/EWS/exchange.asmx");
service.Credentials = new NetworkCredential("001234", "PasswordForUser001234", "Domain");
//Never use this part in production!!
//ServicePointManager.ServerCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
// {
// return true;
// };
var resolvedNames = service.ResolveName("001234");
foreach (var resolvedName in resolvedNames)
{
Console.WriteLine(resolvedName.Mailbox.Address);
}
//FOUND on: http://stackoverflow.com/questions/6081243/get-logged-on-users-smtp-address-via-ews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment