Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching Global Address List/Book

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

like image 217
Patrick Avatar asked Nov 18 '10 01:11

Patrick


People also ask

How do I find global address list?

How do I access the Global Address List? You can access the GAL from the People App in Outlook on the Web (under Directory) or from the Address Book in the Outlook Desktop App on your computer.

How do I search Outlook address book?

Search using the Search Address Books boxOn the Standard toolbar, in the Search Address Books box, type the name of the contact that you want to find. Your Outlook Contacts are searched first. If no match is found, all the other available address books, including any that you have added, are searched.

How do I download global address book?

To download changes to your Offline Global Address List, open Outlook. Under “Send / Receive”, select “Send/Receive Groups”, then “Download Address Book”: Select “Download changes since last Send/Receive”, then choose the address book you want to update: Click OK.


2 Answers

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

like image 86
Steve Townsend Avatar answered Sep 24 '22 03:09

Steve Townsend


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;
like image 26
Jarguess Avatar answered Sep 21 '22 03:09

Jarguess