• Subject: Vba coding with Outlook
  • Author: dmkAlex
  • Date: 13 Apr
  • References:
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: 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
13 AprVba coding with Outlook.dmkAlex
14 Apr|- Re: Vba coding with Outlook.SvenC
14 Apr\ Re: Vba coding with Outlook.JP
15 Apr   \ Re: Vba coding with Outlook.dmkAlex
16 Apr      |- Re: Vba coding with Outlook.SvenC
16 Apr      \ Re: Vba coding with Outlook.JP
All times are in (US) Eastern Daylight Time (GMT -4:00)