Search Tools Links Login

Outlook Contacts as ADO RecordSet

The purpose of this code is to read the Outlook Contacts Folder into an ADO RecordSet. Often you want to let your app use either the Outlook Contacts or your own. This will give you a jump start.

Original Author: Brian Gillham


ADO RecordSet


Sub Outlook_Contacts()
Dim ADOConn As ADODB.Connection
Dim ADORS As ADODB.Recordset
Dim strConn As String
Set ADOConn = New ADODB.Connection
Set ADORS = New ADODB.Recordset
With ADOConn
  'Change the Connection String below
  ' to the correct settings
  .ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Exchange 4.0;MAPILEVEL=Outlook Address Book;PROFILE=Outlook;TABLETYPE=1;DATABASE=c: emp"
End With
  Set .ActiveConnection = ADOConn
  .CursorType = adOpenStatic
  .LockType = adLockReadOnly
  .Open "Select * from [Contacts]"
  'Test: just loop thru the first contact
  Dim i As Long
  For i = 0 To ADORS.Fields.Count - 1
   Debug.Print ADORS(i).Name + _
   vbTab + Format(ADORS(i).Value)
  Next i
End With
Set ADORS = Nothing
Set ADOConn = Nothing
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 129 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.