Creating the Connection String

The following sections contain the information you need to build a connection string to access data in Microsoft Exchange and Outlook folders.

Understanding the Elements of the Connection String

The following table contains a description of the required and optional elements used to create the identifier, source, and options portions of a connection string for a Microsoft Exchange or Outlook external data source.

Element Description
Source Exchange 4.0 (required.) The setting works with Microsoft Exchange 4.x, 5.0, and Outlook data.
Table name MAPILEVEL=storage|folders (required). The storage entry is the exact name of a mailbox on a server, a personal folder, or public folder; and folders is the path to the folder immediately above the folder you want to connect to. The storage entry and the pipe character (|) are always required. The folders entry is required to access folders below the top-level of folders within storage. When you are listing nested folders, separate each folder name with a backslash (\).
Source table type TABLETYPE=0 (for folders) (default)
TABLETYPE=1 (for address books; required)
Database name DATABASE=path (required). The path entry is the path to a Microsoft Access database (.mdb) in which to store system tables used by the driver (usually the current database).
Profile name PROFILE=profile (optional; if not specified, the default profile is used). The profile entry is the name of the Microsoft Exchange or Outlook profile to use.
Password PWD=password (optional; not required if your network logon password is passed to your Microsoft Exchange server). The password entry is the Microsoft Exchange or Outlook logon password.

Building the Connection String

All IISAM drivers accept a connection string that uses the same basic syntax:

"identifier, source, options"

When you are building a connection string to a Microsoft Exchange or Outlook data source, the source argument will always be Exchange 4.0; even if you are working with Microsoft Exchange 5.0 or Outlook. The source argument consists of the table name, source table name, and the database name. The options argument, if used, can consist of settings for either or both the profile name and the password.

The following code sample illustrates a connection string used to link a Microsoft Exchange folder named SampleMessages, which is a subfolder of the Inbox folder, to a Microsoft Jet table named SampleMessages. In this example, strDbPath is the path to the database that will contain the linked table:

Dim dbs As Database
Dim tdf As TableDef
Dim strConnect As String

' Open a Microsoft Jet database.
Set dbs = OpenDatabase(strDbPath)
' Create connection string.
strConnect = "Exchange 4.0;MAPILEVEL=Mailbox - " & _
	"David Jones|Inbox;TABLETYPE=0;" & _
	"DATABASE=" & dbs.Name & ";"
' Create TableDef object in Microsoft Jet database.
Set tdf = dbs.CreateTableDef("SampleMessages")
' Link TableDef object to Microsoft Exchange data source.
With tdf
	.Connect = strConnect
	.SourceTableName = "SampleMessages"
End With
dbs.TableDefs.Append tdf

In the example above, the connection string identifier is Exchange 4.0; and the source is MAPILEVEL="Mailbox - Dave Jones|Inbox;TABLETYPE=0;DATABASE=" & dbs.Name & ";".

The MAPILEVEL= portion of the connection string specifies the path to the folder immediately above the folder you want to access. The SourceTableName property specifies the name of the folder you want to access. The information that appears to the left of the pipe character ( | ) can be any valid mailbox name or any valid local personal folder file. You must preserve any spaces and capitalization that appear in the name.

The DATABASE= portion of the connection string must contain the path and name of an existing Microsoft Access 97 database. Although you may specify any database here, it is preferable to use the current database for this purpose. The specified database is used to store system tables that contain information about the structure of the Microsoft Exchange or Outlook folder.

In the options argument, if the PROFILE argument is omitted, the default profile is used. If the PWD argument is omitted, your network logon password is used. If, for some reason, either of these default values is invalid, you are prompted to enter the correct information.