The information in this article applies to:
SUMMARY
Moderate: Requires basic macro, coding, and interoperability skills.
This article contains a sample procedure to link a Microsoft Outlook
folder as a table in a Microsoft Access database.
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to the "Building
Applications with Microsoft Access 97" manual.
MORE INFORMATION
The example in this article uses the Microsoft Messaging Driver, which you
can install from the Microsoft Data Access Pack in the Office 97 ValuPack.
For more information about obtaining and installing the Microsoft
Messaging Driver, please see the following articles in the Microsoft
Knowledge Base:
ARTICLE-ID: Q159322
TITLE : ACC97: Paradox, Lotus, & MS Exchange/Outlook ISAMs in
ValuPack
ARTICLE-ID: Q161173
TITLE : ACC97: MS Exchange ISAM Driver Requires Manual Registration
The Microsoft Messaging Driver gives you programmatic access to Microsoft
Outlook and Microsoft Exchange mail items. Note that you cannot use this
driver through the user interface in Microsoft Access 97. You must use it
in a Visual Basic for Applications procedure.
There are some issues to consider when you use a linked Microsoft Outlook
folder in Microsoft Access:
The following sample procedure creates a table linked to a folder in a
Microsoft Outlook mailbox. To use the procedure, you must do the following:
- Set up Microsoft Outlook on your computer.
- Set the SourceTableName property in the procedure to the name of the
mail folder you want to attach to your database.
- Substitute valid Connect property parameters for the linked table in
the procedure:
Parameter Value
--------------------------------------------------------------------
MAPILEVEL The path to the parent of the folder you want to link.
DATABASE The path and file name of the current database.
PROFILE A valid Microsoft Outlook or Microsoft Exchange
profile.
- Open the sample database Northwind.mdb.
- Create a module and type the following procedure:
Function AttachMail()
Dim db As Database
Dim td As TableDef
On Error GoTo Errorhandler
Set db = CurrentDb()
Set td = db.CreateTableDef("tblInbox")
' Substitute your own MAPILEVEL, DATABASE and PROFILE arguments.
td.Connect = "Exchange 4.0;MAPILEVEL=Mailbox - Nancy Davolio|;"
td.Connect = td.Connect & "DATABASE=C:\Program Files\Microsoft "
td.Connect = td.Connect & "Office\Office\Samples\Northwind.mdb;"
td.Connect = td.Connect & "PROFILE=Microsoft Outlook"
' Substitute the name of the folder you want to attach.
td.SourceTableName = "Inbox"
db.TableDefs.Append td
Application.RefreshDatabaseWindow
MsgBox "Table Appended!"
Exit Function
Errorhandler:
Msgbox "Error " & Err & " " & Error
Exit Function
End Function
- Press CTRL+G to open the Debug window, type the following line, and
then press ENTER:
?AttachMail()
After the procedure runs, the Inbox mail folder appears as a linked,
read-only table in the database.
REFERENCES
For more information about using the Microsoft Messaging Driver, refer to
the Microsoft Exchange/Outlook Driver section of the Acread80.wri file in
the C:\Program Files\Microsoft Office\Office folder.
For more information about setting the Connect property for a linked
Microsoft Exchange/Microsoft Outlook mail folder, search the Help index
for "Connect property."