Extract Outlook Address book info from VB Application

i am now working on a faxmail client program. i would like to know the way to retrieve information from outlook address book without displaying the address book.( as i have already have the address book displayed by using the Mapimessages control action to show the address book).  I need to search the outlook address book for particular person's info and display it in the VB text boxes. How to do it?
riyugieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

watyCommented:
' #VBIDEUtils#************************************************************
' * Programmer Name  : Jan Amdi
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : jam@pfa.dk
' * Date             : 29/09/99
' * Time             : 14:34
' **********************************************************************
' * Comments         : Get the contacts from an Outlook Contact Database
' * If you have MS Outlook installed you might have organized all your contacts
' * in the Outlook address database. This tip shows you how to get all the contacts
' * in the address database from Visual Basic and put them in a ListBox.
' *
' * Before you begin you need to add a reference to the Outlook 8.0 object library.
' * Start a new project and add the reference from Project -> References and select
' * the 'Outlook 8.0 Object Library'. Add a ListBox to the form (List1).
' *
' * This tip doesn''t apply to MS Outlook Express (All versions).
' *
' **********************************************************************
Option Explicit

Sub GetContactList()

   On Error GoTo Test_Error

   Dim oOutlook As Outlook.Application
   Dim oNameSpace As NameSpace
   Dim oContactFolder As Object
   ' Get the currently opened Outlook session if any. If none is opened
   ' and error (Err = 429) is raised and the Error handler will open a
   ' new session of Outlook.
   Set oOutlook = GetObject(, "Outlook.Application")
   ' Open a MAPI NameSpace
   Set oNameSpace = oOutlook.GetNamespace("MAPI")

   Set oContactFolder = oNameSpace.GetDefaultFolder(olFolderContacts)

   For Each oOutLookAdr In oContactFolder.Item
      List1.AddItem oOutLookAdr.FullName & " - " & oOutLookAdr.Email1Address
   Next

   Exit Sub

Test_Error:

   Select Case Err
      Case 429
         ' If Outlook isn't opened already open a new session.
         ' It might be wise to close the session afterwards.
         Set oOutlook = New Outlook.Application
         Resume Next
      Case Else
         MsgBox Err
   End Select

End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
riyugieAuthor Commented:
what should i dim the oOutlookAdr as ?
As object ? or item? or what
0
riyugieAuthor Commented:
When i run the codes, there is an error saying that the oOutLookAdr variable is not defined... what should i do to proceed ??
0
ishmellCommented:
Just a followup for anyone reading this... the code above needs two things:

add this when dim'n vars

        dim oOutLookAdr as object

and change this line

        For Each oOutLookAdr In oContactFolder.Item

to this (forgot an "s" at the end):

        For Each oOutLookAdr In oContactFolder.Items



-a
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.