CodeItBetter Programming Another VB Programming Blog

How to construct a Recordset of Contacts info from Outlook

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'Database - How to construct a Recordset of Contacts info from Outlook
Sub Main()
    ' You will need to set a refrence to Microsoft Active Data Object 2.x. Code
    Dim Con As ADODB.Connection
    Dim RS As ADODB.Recordset
    Dim I As Long
    Set Con = New ADODB.Connection
    Set RS = New ADODB.Recordset
    With Con
        .ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;" & "Exchange 4.0;" & _
            "MAPILEVEL=Outlook Address Book\;" & "PROFILE=Outlook;" & "TABLETYPE=1;" & _
            "DATABASE=C:\Temp"    'You will need to change this!
        .Open
    End With
    With RS
        Set .ActiveConnection = Con
        .CursorType = adOpenStatic
        .LockType = adLockReadOnly
        .Open "Select * from [Contacts]"
        .MoveFirst
        Do While Not RS.EOF
            For I = 0 To RS.Fields.Count - 1
                Debug.Print RS(I).Name + vbTab + Format(RS(I).Value)
            Next I
            RS.MoveNext
        Loop
        .Close
    End With
    Set RS = Nothing
    Con.Close
End Sub
Filed under: Database Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.