J
Jim Vierra
Sub TestFunction()
OpenOutlookFolder "Outlook", "Personal Folders", "c:\temp"
End Sub
Sub OpenOutlookFolder(strProfile As String, strPSTFolder As String, strDataBase As String)
'Arguments
' strProfile - Outlook profile name
' strPSTFolder - Outlook PST folder name
' strDatabaseTemp - database temporary folder
Dim strOutlook As String
strOutlook = "Outlook 9.0;"
Dim strMAPILevel As String
strMAPILevel = "MAPILEVEL=" & strPSTFolder & "|;" 'Ends with a PIPE char
Dim strTableType As String
strTableType = "TABLETYPE=0;"
strProfile = "PROFILE=" & strProfile & ";"
strDataBase = "DATABASE=" & strDataBase & ";"
Dim oConn As New ADODB.Connection
With oConn
.Provider = "Microsoft.JET.OLEDB.4.0"
.ConnectionString = strOutlook & strProfile & strMAPILevel & strDataBase
.Open
End With
' we can now use SQL to get a recordset of any folder
' contained in the PST.
' Folders within folders can be walked recursively
' as an example we will return the contacts folder
Dim oRS As New ADODB.Recordset
With oRS
.Open "Select * from Contacts", oConn, adOpenStatic, adLockReadOnly
.MoveFirst
Debug.Print oRS(3).Name, oRS(3).Value
Debug.Print oRS(10).Name, oRS(10).Value
.Close
End With
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
End Sub
OpenOutlookFolder "Outlook", "Personal Folders", "c:\temp"
End Sub
Sub OpenOutlookFolder(strProfile As String, strPSTFolder As String, strDataBase As String)
'Arguments
' strProfile - Outlook profile name
' strPSTFolder - Outlook PST folder name
' strDatabaseTemp - database temporary folder
Dim strOutlook As String
strOutlook = "Outlook 9.0;"
Dim strMAPILevel As String
strMAPILevel = "MAPILEVEL=" & strPSTFolder & "|;" 'Ends with a PIPE char
Dim strTableType As String
strTableType = "TABLETYPE=0;"
strProfile = "PROFILE=" & strProfile & ";"
strDataBase = "DATABASE=" & strDataBase & ";"
Dim oConn As New ADODB.Connection
With oConn
.Provider = "Microsoft.JET.OLEDB.4.0"
.ConnectionString = strOutlook & strProfile & strMAPILevel & strDataBase
.Open
End With
' we can now use SQL to get a recordset of any folder
' contained in the PST.
' Folders within folders can be walked recursively
' as an example we will return the contacts folder
Dim oRS As New ADODB.Recordset
With oRS
.Open "Select * from Contacts", oConn, adOpenStatic, adLockReadOnly
.MoveFirst
Debug.Print oRS(3).Name, oRS(3).Value
Debug.Print oRS(10).Name, oRS(10).Value
.Close
End With
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
End Sub