How to use "Look up Outlook Contact" function with code? VSTO 2005



In Outlook 2003, if you open a message and hover over the name in the From
field, a menu appears with "Look up Outlook Contact" as one of the menu items
which will either open up a Contact or display a message stating that no
matching contact was found.

I would like to be able to use code in my VSTO 2005 Add-In to open a message
and check to see if there is a matching Contact. If so, I want to set some of
the UserProperties of the Contact Item.

Currently, I am searching for a string in the Subject of the Inbox items and
when one is found, I then loop through all of the Contacts to find a matching
email address. This seems to me to be the slow way of doing it although it
does work.

It would probably be much faster to be able to open up a Contact item using
code the same way that a user can open up a Contact item by using the "Look
up Outlook Contact" function.

Is this possible or is looping through the Contacts collection and comparing
email addresses the only way?



Ken Slovak - [MVP - Outlook]

One way or the other you're going to be comparing email addresses. How
quickly that goes depends on how you do that.

If using the Outlook object model probably the quickest way is to use a
Restriction on the Items collection of each contacts folder, restricting
first on Email1Address then on Email2Address then on Email3Address.

Once you have that contact item getting its EntryID and an object reference
to the contact and then displaying it is easy.

A much quicker way would be to use a lower level API such as Extended MAPI
(which is what Outlook does but it can only be programmed using C++ or
Delphi) or something like Redemption (an Extended MAPI wrapper) and using a
filtered MAPITable. That would be anywhere from 10 to 100 times faster than
using the Outlook object model.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question