Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retreiving Names form the Global Address List

Status
Not open for further replies.

ACraib

MIS
Sep 7, 2001
579
GB
Hi

I am new to Access. I've created a database where one of the fields are users on my network names. I would like to be able to have this field resolve itself from the GAL .... the same way that Outlook does when creating a new message.

An ambitious task for a beginner so easy instructions would be great.

Thanks for your help.

Andrew
 
First add the outlook object library to your references (TOOLS|REFERENCES I think)
The following code will give you a message box with the first entry in your global address list. Iterate through the myaddresses collection to get them all (the total number is in the property myaddresses.count)

Dim myapp As Outlook.Application
Dim myns As Outlook.NameSpace
Dim mylists As Outlook.AddressLists
Dim mylist As Outlook.AddressList
Dim myaddresses As Outlook.AddressEntries
Dim myaddress As Outlook.AddressEntry


Set myapp = New Outlook.Application
Set myns = myapp.GetNamespace("MAPI")
Set mylists = myns.AddressLists
Set mylist = mylists.Item("Global Address List")
Set myaddresses = mylist.AddressEntries
ReDim myaddress(myaddresses.Count)
Set myaddress = myaddresses.GetFirst
MsgBox myaddress.Name

Set myaddress = Nothing
Set myaddresses = Nothing
Set mylists = Nothing
Set mylist = Nothing
Set myns = Nothing
Set myapp = Nothing



There is extensive documentation of the Outlook Object Hierarchy in the Outlook Help files under advanced customization-Microsoft Outlook Visual Basic Reference

JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top