
COM Addin to track email, Outlook, VB6
Is it possible to create a COM addin that will simply write to a text file
the name of sender and date of email? I created an Addin in VB6 with the
Addin option at start up. All I have left is the Connect.DSR, which I placed
the following code:
Dim olOutlook As Outlook.Application
Dim WithEvents olMail As Outlook.Application
Private Sub AddinInstance_OnConnection(ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal
AddInInst As Object, custom() As Variant)
Set olMail = Outlook.Application
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
Set olMail = Nothing
End Sub
Private Sub olMail_NewMail()
Dim myItems As Outlook.Items
Dim olMailObject As Outlook.MailItem
Dim intFreeFile As Integer
Set myItems = Application.GetNamespace("MAPI").GetDefaultFolder
(olFolderInbox).Items
Set olMailObject = myItems.Item(1)
intFreeFile = FreeFile
Open "C:\MailInfo.txt" For Append As intFreeFile
Write #intFreeFile, olMailObject.SenderName,
olMailObject.ReceivedTime
Close intFreeFile
End Sub
My problem is that it will not fire off the New Mail event. Am I missing
something? Thanks
Bill Mountford