Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook information from selected contactitem

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.

like image 610
Bi0logiCaL Avatar asked Feb 01 '26 15:02

Bi0logiCaL


1 Answers

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;
}
like image 152
SliverNinja - MSFT Avatar answered Feb 04 '26 04:02

SliverNinja - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!