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

  • Thread starter Thread starter G Elliott
  • Start date Start date
G

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
Next

'Cleanup
Set olNS = Nothing
Set olAddrEntries = Nothing

End Sub


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