Solved

Help!!How du u read the outlook address book

Posted on 2000-05-06
5
136 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
ID: 2784603
0
 

Expert Comment

by:AZWolf7
ID: 2784616
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
ID: 2784700
Thanks AzraSound !!
0
 

Author Comment

by:Portal111
ID: 2784708
Thanks guys
0
 

Author Comment

by:Portal111
ID: 2784728
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 223
How to set the sa password in a vb6 code for sql connection 9 60
MsgBox 4 68
VB 6 error 5 in windows 10 but not in XP 7 63
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

861 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