I am trying to get Information of the selected ContactItem in Outlook 2010. Such data as: "Name, CompanyName, Adress" etc. pp.
I need this Information to be loaded into my WinForm and be shown as TEXT in a couple of Labels on the Form. The Wordprocess is as follows: Right Click on wished Contact in Outlook > Click on the ContextMenu (AddIn) I created.
Here is an example that should give you the ContactItem
reference from the Explorer.Selection
. You can then access all the ContactItem
properties from the current active selection. If you want to support multiple ContactItems
selected, you would have to change the behavior slightly.
Outlook.Selection selection = Globals.ThisAddIn.Application.ActiveExplorer().Selection;
if (selection.OfType<Outlook.ContactItem>().Count() == 1) // only support single item selection
{
Outlook.ContactItem contact = selection.OfType<Outlook.ContactItem>().FirstOrDefault();
string name = contact.FullName;
string company = contact.CompanyName;
string address = contact.BusinessAddress;
}