dreammaker888
Programmer
In the Outlook vba help file, it said . . .
"This Microsoft Visual Basic/Visual Basic for Applications (VBA) example displays the Inbox folder when a new e-mail message arrives. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.
"
The following is what I wrote in code and I put it in Class1 of the class module:
When I receive a new email, it doesn't seem to activate this block of routine.
What am I doing wrong?
I am not familiar with class module at all.
Thanks.
dmk
"This Microsoft Visual Basic/Visual Basic for Applications (VBA) example displays the Inbox folder when a new e-mail message arrives. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.
"
The following is what I wrote in code and I put it in Class1 of the class module:
Code:
Public WithEvents myOlApp As Outlook.Application
Sub Initialize_handler()
Set myOlApp = CreateObject("Outlook.Application")
End Sub
Private Sub myOlApp_NewMail()
Dim myExplorers As Outlook.Explorers
Set myExplorers = myOlApp.Explorers
Dim myItem As Outlook.MailItem
Set myItem = myOlApp.ActiveInspector.CurrentItem
If myItem.Subject = "Testing" Then
MsgBox "This message is a test message."
End If
End Sub
When I receive a new email, it doesn't seem to activate this block of routine.
What am I doing wrong?
I am not familiar with class module at all.
Thanks.
dmk