Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


Keywords: KB275262, kbvba, kbado, kbprogramming, kbdatabase, kbprovider, kbhowto

↑ Back to the top

Article Info
Article ID : 275262
Revision : 3
Created on : 7/28/2004
Published on : 7/28/2004
Exists online : False
Views : 276