O
Ondine
Hi
I understand that it's not possible to view certain Outlook data/fields via
linked tables. I need to be able to work with the sender's email addresses
for received email in a particular folder (Vouchers), and all I'm getting in
a linked Outlook/Exchange table is the Display Name which is useless.
I know it should be possible to access this information via VBA but can't
find the right code. I have used the following code to get as far as listing
the field names (with thanks to Michael Kaplan):
Public Sub EnumerateChildren( _
Optional ByVal fFolders As Boolean, _
Optional ByVal iLevel As Long = 1, _
Optional ByVal stMapiLevel As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim stConnect As String
Dim fld As DAO.Field
Dim rst As DAO.Recordset
stConnect = "Exchange 4.0;MAPILEVEL=" & _
stMapiLevel & ";"
stConnect = stConnect & "TABLETYPE=" & _
Abs(Not fFolders) & ";"
Set db = OpenDatabase("c:\temp\", False, _
False, stConnect)
iLevel = iLevel + 1
For Each tdf In db.TableDefs
'Debug.Print String$(iLevel - 1, " ") & tdf.Name
If (tdf.Attributes And FT_HASSUBFOLDERS) = _
FT_HASSUBFOLDERS Then
Call EnumerateChildren(fFolders, iLevel, _
AlterMapiLevel(stMapiLevel, tdf.Name, _
iLevel, fFolders))
End If
If tdf.Name = "Vouchers" Then
For Each fld In tdf.Fields
Debug.Print fld.Name
Next fld
End If
Next tdf
End Sub
Public Function AlterMapiLevel( _
stMapiLevel As String, _
stChild As String, _
ByVal iLevel As Long, _
fFolder As Boolean) As String
If Not fFolder Then
iLevel = iLevel - 1
End If
Select Case iLevel - 1
Case 1
AlterMapiLevel = stChild & "|"
Case Else
AlterMapiLevel = stMapiLevel & "\" & _
stChild & "\"
End Select
End Function
However I can't get my head around grabbing the data. There is obviously
some way to open a recordset on the tabledef but I'm stuck.
Can anyone please help??
Many thanks.
Ondine.
I understand that it's not possible to view certain Outlook data/fields via
linked tables. I need to be able to work with the sender's email addresses
for received email in a particular folder (Vouchers), and all I'm getting in
a linked Outlook/Exchange table is the Display Name which is useless.
I know it should be possible to access this information via VBA but can't
find the right code. I have used the following code to get as far as listing
the field names (with thanks to Michael Kaplan):
Public Sub EnumerateChildren( _
Optional ByVal fFolders As Boolean, _
Optional ByVal iLevel As Long = 1, _
Optional ByVal stMapiLevel As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim stConnect As String
Dim fld As DAO.Field
Dim rst As DAO.Recordset
stConnect = "Exchange 4.0;MAPILEVEL=" & _
stMapiLevel & ";"
stConnect = stConnect & "TABLETYPE=" & _
Abs(Not fFolders) & ";"
Set db = OpenDatabase("c:\temp\", False, _
False, stConnect)
iLevel = iLevel + 1
For Each tdf In db.TableDefs
'Debug.Print String$(iLevel - 1, " ") & tdf.Name
If (tdf.Attributes And FT_HASSUBFOLDERS) = _
FT_HASSUBFOLDERS Then
Call EnumerateChildren(fFolders, iLevel, _
AlterMapiLevel(stMapiLevel, tdf.Name, _
iLevel, fFolders))
End If
If tdf.Name = "Vouchers" Then
For Each fld In tdf.Fields
Debug.Print fld.Name
Next fld
End If
Next tdf
End Sub
Public Function AlterMapiLevel( _
stMapiLevel As String, _
stChild As String, _
ByVal iLevel As Long, _
fFolder As Boolean) As String
If Not fFolder Then
iLevel = iLevel - 1
End If
Select Case iLevel - 1
Case 1
AlterMapiLevel = stChild & "|"
Case Else
AlterMapiLevel = stMapiLevel & "\" & _
stChild & "\"
End Select
End Function
However I can't get my head around grabbing the data. There is obviously
some way to open a recordset on the tabledef but I'm stuck.
Can anyone please help??
Many thanks.
Ondine.