This article shows you how to create a sample procedure to link a Microsoft
Outlook folder as a table in a Microsoft Access database.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. NOTE
: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References
on the Tools
menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library
check box is selected.
There are some issues to consider when you use a linked Microsoft Outlook
folder in Microsoft Access:
- You cannot select which fields appear in the linked table; a subset of the total number of Microsoft Outlook fields appears in the table. However, you can rearrange or hide the fields in Datasheet view of the table to customize its appearance.
- You can add and delete records, but you cannot modify any records in the table.
- You cannot enter data into some fields in the linked table, even when you are adding a new record.
- If items in the linked Microsoft Outlook folder use a special form, you must enter the correct form type in the Message Class field when you add new records to the table. If you do not specify a Message Class, Microsoft Outlook uses the default mail form to display your data. The Message Classes for the standard Microsoft Outlook folders are:
Collapse this tableExpand this table
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 that you want to link to your database.
- Substitute valid Connect property parameters for the linked table in the procedure:
Collapse this tableExpand this table
|MAPILEVEL||The path to the parent of the folder that you want to link|
|DATABASE||The path and file name of the current database|
|PROFILE||A valid Microsoft Outlook or Microsoft Exchange profile|
You can open a table that is linked to a Microsoft Outlook or Microsoft
Exchange folder if that table's Connect
property does not contain a profile parameter. However, when you open the table, you may have to supply profile information multiple times, instead of just once.
- Open a Microsoft Access 2000 database.
- Create a new module and enter the following:
Option Compare Database
'This code requires that the following object library be referenced:
' Microsoft DAO 3.6 Object Library.
Dim db As DAO.Database
Dim td As DAO.TableDef
On Error GoTo Errorhandler
Set db = CurrentDb()
Set td = db.CreateTableDef("tblInbox")
'Within the following line, replace <mailbox name> with the actual
'Exchange mailbox name created on your computer. For example:
' Nancy Davolio
td.Connect = "Exchange 4.0;MAPILEVEL=Mailbox - <mailbox name>|;"
'Within the following line, replace <drive\path\dbname> with the
'actual path to the database. For example:
' C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb
'This will also support UNC (for example, \\servername\share\dbname).
td.Connect = td.Connect & "DATABASE=<drive\path\dbname>;"
'Within the following line, replace <profile name> with the actual
'name of your email profile created on your computer. For example:
' Microsoft Outlook
td.Connect = td.Connect & "PROFILE=<profile name>"
'Substitute the name of the email folder you wish to attach.
'In this example, we will attach the Inbox folder.
td.SourceTableName = "Inbox"
MsgBox "Table Appended!"
MsgBox "Error " & Err & " " & Error
- Press CTRL+G to open the Immediate window, type the following line, and then press ENTER:
Note that after the procedure runs, the e-mail folder will be linked as a read-only table in the database.
For more information about setting the Connect property for a linkedMicrosoft Exchange/Microsoft Outlook mail folder, click Microsoft Visual Basic Help
menu, type connect property
in the Office Assistant or
the Answer Wizard, and then click Search
to view the topics
Article ID: 209946 - Last Review: October 25, 2013 - Revision: 3.0
- Microsoft Access 2000 Standard Edition
|kbnosurvey kbarchive kbdta kbhowto kbole kbusage KB209946|