Solved

Help!!How du u read the outlook address book

Posted on 2000-05-06
5
130 Views
Last Modified: 2010-05-02
I would like to know how u can read outlooks address book and input it into a listbox in VB.

Thanks
Jack
0
Comment
Question by:Portal111
  • 3
5 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 150 total points
Comment Utility
0
 

Expert Comment

by:AZWolf7
Comment Utility
Here is some sample code. Create a new project, and set a reference to CDO 1.21 (or whatever version you have), Create a form with a listbox called list1, and a button called Command1. Here's the code...

Private Sub Command1_Click()

    Dim objSession As Session
    Dim objPAB As AddressList
    Dim objEntries As AddressEntries
    Dim objEntry As AddressEntry
    Dim idx As Integer
   
    Set objSession = New Session
    objSession.Logon ShowDialog:=True
   
    If objSession Is Nothing Then Exit Sub
    Set objPAB = objSession.GetAddressList(0)

    'substitute 1 for the 0 above for the personal address book
    If objPAB Is Nothing Then Exit Sub
    Set objEntries = objPAB.AddressEntries
   
    For idx = 1 To objEntries.Count
        Set objEntry = objEntries.Item(idx)
        List1.AddItem objEntry.Name
    Next idx

End Sub

You'd probably want to close your session and set the objects = nothing when you are done....
0
 

Author Comment

by:Portal111
Comment Utility
Thanks AzraSound !!
0
 

Author Comment

by:Portal111
Comment Utility
Thanks guys
0
 

Author Comment

by:Portal111
Comment Utility
Alright AZWolf7, thanks for the code but when i try it it says "User-defined type not defined" and i don't know what to do, i have tried everything.
Thanks, Jack
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now