tfurnivall
Registered User.
- Local time
- Today, 07:07
- Joined
- Apr 19, 2012
- Messages
- 81
Vacation can get ruined fast when you don't have the right manuals available!
I have this project that I'm working on which needs to process a whole load of Outlook message items into an Access database (some metadata - not the actual MailItems themselves). The top level procedure (CalculateRelevancyScores) is given here:
It includes 'external' references to ADO, all of which work fine, including the use of the word "New". I have a subsidiary function (GetNextMessage) which returns an Outlook MailItem. I have the appropriate references (Microsoft Outlook 14.0 Object Library).
Because I might be looking at either a pst file, containing real genuine MailItems, or at a database table from which I must reconstitute some of the metadata into a new MailItem, I need to create such a MailItem. That's what I'm trying to do in this code:
I added the intermediate step of trying to create m, but noway does VBA like what I have. Yet it seems to me, at least, that the syntax is correct.
Any ideas? Suggestions?
Thanks, as usual, in advance,
Tony
I have this project that I'm working on which needs to process a whole load of Outlook message items into an Access database (some metadata - not the actual MailItems themselves). The top level procedure (CalculateRelevancyScores) is given here:
Code:
Sub CalculateRelevancyScores()
' Calculate the relevancy scores for all mails in all the extract files (.pst files)
Dim ContentCount As Long
Dim LocationCount As Long
Dim ParticipantCount As Long
Dim SourceFileAvailable As Boolean
Dim SourceFileName As String
Dim SourceFile As Long
Dim SourceFileHasRecords As Boolean
Dim MyMessage As Outlook.MailItem
Dim MyMessageEntry As RelevanceMessage
Dim MyConnection As ADODB.Connection
Dim Participants As ADODB.Recordset
Dim ContentTerms As ADODB.Recordset
Dim Locations As ADODB.Recordset
InitializeEnvironment MyConnection, ProcessAudit
Set Participants = New ADODB.Recordset
Set ContentTerms = New ADODB.Recordset
Set Locations = New ADODB.Recordset
LoadControlFiles MyConnection, Participants, ContentTerms, Locations
Do
SourceFileAvailable = GetNextSourceFile(SourceFileName)
If SourceFileAvailable Then
InitializeSourceFile SourceFileName
Set MyMessage = GetNextMessage(SourceFile, SourceFileHasRecords)
While SourceFileHasRecords
' Process this message
Set MyMessageEntry = InitializeMessageEntry(MyMessage)
' Lastly, get the next message (if any)
MyMessage = GetNextMessage(SourceFile, SourceFileHasRecords)
Wend
End If
Loop Until Not SourceFileAvailable
Participants.Close
Set Participants = Nothing
Participants.Close
Set Participants = Nothing
ContentTerms.Close
Set ContentTerms = Nothing
Locations.Close
Set Locations = Nothing
End Sub
Because I might be looking at either a pst file, containing real genuine MailItems, or at a database table from which I must reconstitute some of the metadata into a new MailItem, I need to create such a MailItem. That's what I'm trying to do in this code:
Code:
Function GetNextMessage(SourceFile As Long, SourceFileHasRecords As Boolean) As Outlook.MailItem
Dim m As Outlook.MailItem
' The global variable ScanSource indicates whether we are reading an external PST file (described in
' SourceFileName) or the Messages Table of the database.
Set m = New Outlook.MailItem
Set GetNextMessage = m
End Function
Any ideas? Suggestions?
Thanks, as usual, in advance,
Tony