Searching Global Address List/Book

Patrick picture Patrick · Nov 18, 2010 · Viewed 12.9k times · Source

I'm developing an app that will allow the user user to view the contents of an inbox that they have access to. I am having a difficult time trying to find a means of searching the Global Address List other then

AddressEntries entries = global.AddressEntries;
AddressEntry entry = entries["search value"];

This works but only returns one instance, and it is the first one found. I basically want to provide a list to the user if there are multiple results.

Secondly I would like to be able to view the contact details, but when I use the

ContactItem contact = entry.GetContact();

It always returns null, I think that it is because it is looking at the current user's contact personal list

I guess that I am trying to create a simple version of the Global Address Book window in Outlook, if that makes sense.

Anyway if anyone has any ideas or references I would be grateful!

Thanks Patrick

Answer

Steve Townsend picture Steve Townsend · Nov 18, 2010

You should be able to get the Global Address List from current profile as shown below.

Outlook.AddressLists addrLists = Application.Session.AddressLists;
Outlook.AddressList gal = addrLists["Global Address List"];

Then you can enumerate and display the members of that AddressList.

There's another way to do this described on MSDN here.

How to: Enumerate the Entries in the Global Address List