That might be a great solution. You'd still have the manual VBA
installation issue, but with a lot less code to replace >if vbaproject.otm
corrupts (as it has been known to do).
That's my standard solution using a normal VB 6 ActiveX DLL.
With Word, Excel, etc., I use a setup program that actually creates the code
and adds the reference in the template/workbook. Alas, since the Outloook
object model does not expose the VBProject, there's a silly, unnecessary
roadblock to proper setup programs with Outlook.
With an ActiveX DLL, I can use a setup program to register the critter, but
the user will have to manually insert a reference in the VBAProject.otm..
With a COM add-in, I guess the effective difference is that the user won't
have to include a reference to the DLL, but will still have to manually
insert the stubs.
ThisOutlookSession would require code like
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
EFItemSend Item
End Sub
Private Sub Application_Quit()
TerminateMyMailFilters 2
End Sub
Private Sub Application_Startup()
SetupMyMailFilters 1
End Sub
And there would need to be a standard module in vbaproject.otm like the code
below.
I can make the module an importable .bas file, but the ThisOutlookSession
stuff would have to be entered manually, as well as the reference to the
DLL.
Why in the world was the Outlook object model so crippled? Makes no sense?
Public EF As clsMyMailFilters
Public Sub MyIncomingFilters(objMsg As Outlook.MailItem)
' SetupClass
EF.ProcessIncomingFilters objMsg
End Sub
Public Sub SetupMyMailFilters(lngDummy As Long)
' SetupClass
Set EF = New clsMyMailFilters
EF.ReadMyMailFilterFile
End Sub
Public Sub TerminateMyMailFilters(lngDummy As Long)
Set EF = Nothing
End Sub
Public Sub EFItemSend(ByVal Item As Object)
If TypeName(Item) = "MailItem" Then
With Item
' Code to be determined
'Debug.Print "Outgoing:" & vbCrLf _
& "SenderEmailAddress:" & .SenderEmailAddress & vbCrLf _
& "SenderName:" & .SenderName & vbCrLf _
& "Subject:" & .Subject & vbCrLf _
& "To:" & .To & vbCrLf _
& "Cc:" & .CC & vbCrLf _
& "Importance:" & .Importance & vbCrLf _
& "Bcc:" & .BCC & vbCrLf _
& "Body: " & vbCrLf _
& .Body
End With
End If
End Sub