ACC97: Exchange/Outlook Driver Example Incorrect in Acread80.wri (163067)
The information in this article applies to:
This article was previously published under Q163067 Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
In the Microsoft Access 97 Readme file, Acread80.wri, the following code
sample in the Microsoft Exchange/Outlook Driver section is incomplete:
To open a Microsoft Exchange/Outlook folder directly, use the
OpenDatabase method and specify values for the following parts:
database, options = True, read-only = True, and a dbname data source.
The following code example uses the OpenDatabase method to open a
Microsoft Exchange/Outlook folder named Barbara and count the number of
messages received from a user named Jim Harris:
Public Sub OpenExchangeFolder()
Dim dbsExchange As Database, intCount As Integer
Dim rst As Recordset, str As String
str = "Exchange 4.0;MAPILEVEL=" _
& "Dave Jones (Exchange)|People\Important;TABLETYPE=0;"
Set dbsExchange = OpenDatabase _
("C:\Data\Temp.mdb", 0, 0, str)
Set rst = dbsExchange.OpenRecordset("Barbara")
rst.MoveFirst
While Not rst.EOF
If rst!From = "Jim Harris" Then
intCount = intCount + 1
End If
rst.MoveNext
Wend
rst.Close
dbsExchange.Close
End Sub
RESOLUTION
The Database and Profile arguments are missing from the str variable in
the code example, which is used as the connect parameter for the
OpenDatabase method. The Database argument indicates the Microsoft Access
database in which to open the Microsoft Outlook/Exchange recordset; the
Profile argument indicates the Microsoft Outlook/Exchange profile to use
when you open the recordset. You can view the profiles you have set up on
your computer by double-clicking the Mail icon in Control Panel. When the
Microsoft Outlook Properties dialog box appears, click Show Profiles.
NOTE: You can download the Exchange/Outlook Wizards from Microsoft's Web
site on the Internet. The wizard enables you to import or link to
Microsoft Exchange/Outlook data without writing Visual Basic code. The
wizards are available at http://www.microsoft.com/accessdev/a-free.htm.
Modify the example to include the Database and Profile arguments:
Public Sub OpenExchangeFolder()
Dim dbsExchange As Database, intCount As Integer
Dim rst As Recordset, str As String
str = "Exchange 4.0;MAPILEVEL=" _
& "Dave Jones (Exchange)|People\Important;TABLETYPE=0;" _
& "DATABASE = C:\Data\Temp.mdb;PROFILE = Microsoft Outlook"
Set dbsExchange = OpenDatabase _
("C:\Data\Temp.mdb", 0, 0, str)
Set rst = dbsExchange.OpenRecordset("Barbara")
rst.MoveFirst
While Not rst.EOF
If rst!From = "Jim Harris" Then
intCount = intCount + 1
End If
rst.MoveNext
Wend
rst.Close
dbsExchange.Close
End Sub
REFERENCES
For more information about using the OpenDatabase method to connect to a
Microsoft Outlook/Exchange folder, search the Help Index for "OpenDatabase
Method."
For more information about the Microsoft Outlook/Exchange connect
argument, search the Help Index for "Connect property."
For more examples of linking a Microsoft Outlook/Exchange folder as a
Microsoft Access 97 table, please see the following article in the
Microsoft Knowledge Base:
161174 ACC97: Sample Procedure to Attach a Microsoft Outlook Folder
Modification Type: | Major | Last Reviewed: | 9/25/2003 |
---|
Keywords: | KB163067 |
---|
|