I have a client app written using EWS Managed API 1.1. Here's the situation:
I can connect to EWS just fine, send messages, etc.
However my software needs to discover the authenticated user's email address, and for various requirements reasons can't just ask the user to provide it.
I assumed I'd be able to get such a simple detail back from the web service, but I'm stumped!
Is this possible for both 2007 and 2010?
Thanks!
Sign in to your Exchange admin center. Go to recipients > mailboxes and check the email address shown in the EMAIL ADDRESS column. This is the primary SMTP address (Fig. 2.).
Our integration with Exchange/Outlook Calendar requires the address of your Exchange server, called EWS URL (Exchange Web Services URL). This is usually auto-detected using your email address, but sometimes the auto-detection may fail. A common cause of failure is when your Exchange admin disabled auto-detection.
The URL of Exchange Web Services for the mailbox is the URL: https://MAIL-SERVER/EWS/Exchange.asmx.
You may be able to do it using ExchangeService.ResolveName
. I tried it with the following EWS Managed API code example on Exchange 2007 and it worked like a charm:
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri("https://serv/EWS/exchange.asmx");
service.Credentials = new NetworkCredential("001234", "PasswordForUser001234", "Domain");
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With