Getting cdoPR fields for names listed in Global Address List - err


G Elliott

I want to access several fields for names listed in the GAL, such as
Department, Phone, etc. I found this sample code for Visual Basic, and
modified a few little things. I confirmed that CDO 1.2.1 is installed, and I
enabled the checkbox in Tools/References in my VB project.

FYI - code runs fine thru this command:
Debug.Print olAddrEntries.Item(i).Name

Error occurs at this line in the code -
Debug.Print olAddrEntries.Item(i).Fields(CdoPR_DEPARTMENT_NAME).Value

Here is the code:

Public Sub RetrieveStaffInfo()

Dim objOutlook
Dim olNS
Set objOutlook = CreateObject("Outlook.application")
Set olNS = objOutlook.GetNameSpace("MAPI")

'Get address book list
Dim olAddrEntries
Set olAddrEntries = olNS.AddressLists.Item(1).AddressEntries

Dim i As Integer

'Output names of those in the Global Address Book
For i = 1 To olAddrEntries.Count

Debug.Print olAddrEntries.Item(i).Name
Debug.Print olAddrEntries.Item(i).Fields(CdoPR_DEPARTMENT_NAME).Value

Set olNS = Nothing
Set olAddrEntries = Nothing

End Sub

I appreciate any advice!! (I've already been to CDOLive and several other
resources. seems to be down today)

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