Outlook getting a default email

59 views Asked by At

I need to get the default email (which is selected in File > Account Settings > Account Settings).

I have tried to get it in different ways:

var outlookApp = new Application();
var defaultEmail = OutlookApp.Session.DefaultStore.DisplayName;

var outlookNamespace = outlookApp.GetNamespace("MAPI");
defaultEmail = outlookNamespace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Store.DisplayName;

defaultEmail = outlookNamespace.DefaultStore.DisplayName;

But all ways return the email of my Exchange account, not the default email I chose (e.g. [email protected]). Is there any way to get the default email?

1

There are 1 answers

2
Dmitry Streblechenko On

Use Application.Session.CurrentUser.AddressEntry.

From there, you can either use AddressEntry.Address or, in case of an Exchange account, AddressEntry.GetExchangeUser().PrimarySmtpAddress