How to retrieve Exchange and Outlook data with the Jet 4.0 OLE DB provider in Access 2000 (275262)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q275262
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SUMMARY

This article describes how you can open a connection to a Microsoft Exchange or to a Microsoft Outlook mailbox by using ActiveX Data Objects (ADO) and the Jet OLE DB provider.

MORE INFORMATION

The following example opens a connection to an Exchange or to an Outlook mailbox, and then prints out the subject and the date received values of the first record in the Calendar.

NOTE: Steps 1 through 3 show you how to determine the name of your mailbox. If you already know the name of your mailbox, go to step 4.
  1. Click Start, point to Settings, and then click Control Panel.
  2. In Control Panel, open the Mail tool.
  3. Click the Delivery tab to see the list of available mailboxes. Your mailbox name is in the Deliver new mail to the following location box.
  4. In an Access database, create a new module, and then paste or type the following code.

    NOTE: In the connection string, change the name James Smith to your mailbox name, and make sure the path to the Temp folder is correct for your system. Keep in mind that the spaces, the minus sign, and the vertical bar character are required in the string.
    Sub OpenExchange_Calendar()
        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
            .Provider = "Microsoft.JET.OLEDB.4.0"
            .ConnectionString = "Exchange 4.0;" _
                                & "MAPILEVEL=Mailbox - James Smith|;" _
                                & "PROFILE=MS Exchange Settings;" _
                                & "TABLETYPE=0;DATABASE=C:\WINDOWS\TEMP\;"
            .Open
        End With
        
        With ADORS
            .Open "Select * from Calendar", ADOConn, adOpenStatic, _
                   adLockReadOnly
            .MoveFirst
                Debug.Print ADORS(3).Name, ADORS(3).Value
                Debug.Print ADORS(10).Name, ADORS(10).Value
            .Close
        End With
        
        Set ADORS = Nothing
        ADOConn.Close
        Set ADOConn = Nothing
    
    End Sub
    					
  5. In the Immediate window, type the following line, and then press ENTER:
    OpenExchange_Calendar
    					
Note that the name of the first contact in your contacts folder appears in the Immediate window.

Modification Type:MinorLast Reviewed:7/28/2004
Keywords:kbProgramming kbDatabase kbProvider KbVBA kbADO kbhowto KB275262