How do I get the displayname of the logged in user in EWS?

Posted by tig on Stack Overflow See other posts from Stack Overflow or by tig
Published on 2011-11-30T17:48:59Z Indexed on 2011/11/30 17:49 UTC
Read the original article Hit count: 392

Filed under:
|
|

Exchange Autodiscovery will give me the user's Display Name via the UserSettingName.UserDisplayName property.

However, in cases where autodiscovery fails and connection needs to be done manually I can't figure out how to get the DisplayName.

I tried this, but I just get the users' email address:

 _service = new ExchangeService();
 _service.Credentials = new System.Net.NetworkCredential(exchangeSettings.EmailAddress, exchangeSettings.Password);
 _service.Url = new Uri(exchangeSettings.ExternalEwsUrl);

 NameResolutionCollection resolvedNames = _service.ResolveName(exchangeSettings.EmailAddress);
 exchangeSettings.UserDisplayName = resolvedNames.First().Mailbox.Name;

Thanks

© Stack Overflow or respective owner

Related posts about exchange

Related posts about ews