Retrieving Email Addresses in Outlook

Sometimes it seems that what we thought was the easiest problem to solve actually turns out taking the longest amount of time to figure out.

Case in point – finding the email address of the currently logged in user running Outlook in a VSTO plugin.

If you are looking to do this, see below and let the code set you free.

Recipient CurrentUser = this.Application.Session.CurrentUser;

CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress.ToString()

A little longer and less direct than I would have thought (i.e., at this stage, my user is not a recipient to anything) but the reasoning becomes a little more apparent if I am trying to find the email addresses on a set of recipients on either an appointment or mail message.

.Recipients[1].AddressEntry.GetExchangeUser().PrimarySmtpAddress.ToString()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s