Search Global Address / Book List

I am developing an application that will allow the user to view the contents of the incoming mail to which they have access. I have a hard time trying to find a way to search the Global Address List and then

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

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

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

 ContactItem contact = entry.GetContact(); 

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

I suppose I'm 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 links, I would be grateful!

Thanks Patrick

+4
source share
2 answers

You can get the global address list from the current profile, as shown below.

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

You can then list and display the elements of this AddressList .

Another way to do this is described in MSDN here .

How to: List entries in the Global Address List

+3
source
 string[] names; Outlook.AddressLists addrLists = Application.Session.AddressLists; Outlook.AddressList gal = addrLists["Global Address List"]; //for a distrubution list do this... Outlook.AddressEntry entry = gal.AddressEntries["distribution list"]; Outlook.ExchangeDistributionList exchDL = entry.GetExchangeDistributionList(); Outlook.AddressEntries addrEntries = exchDL.GetExchangeDistributionListMembers(); names = new string[addrEntries.Count]; for (int i = 0; i < addrEntries.Count; i++) { Outlook.AddressEntry exchDLMember = addrEntries[i]; names[i] = exchDLMember.Name; } return names; //for an individual you could do something like this... Outlook.AddressEntry entry = gal.AddressEntries["contact nickname"]; Outlook.ContactItem contact = entry.GetContact(); string name = contact.NickName; string email = contact.Email1Address; 
+4
source

All Articles