Reputation: 13
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?
Upvotes: 0
Views: 104
Reputation: 66286
Use Application.Session.CurrentUser.AddressEntry
.
From there, you can either use AddressEntry.Address
or, in case of an Exchange account, AddressEntry.GetExchangeUser().PrimarySmtpAddress
Upvotes: 0