vbaeventsoutlookoutlook-2003

outlook event newMail (newItem)


I'm working with outlook 2003

I search a way to get the event when a new mail is created (when the window of new mail is created)

Note: I search every way to add a menu to new mail window)


Solution

  • This sample code should be placed in the ThisOutlookSession module. Restart Outlook and whenever you create a new email you will see the message box.

    Private WithEvents objinspectors As Outlook.Inspectors
    
    Private Sub Application_Startup()
      Set objinspectors = Application.Inspectors
    End Sub
    
    Private Sub objinspectors_NewInspector(ByVal Inspector As Inspector)
      If TypeName(Inspector.CurrentItem) = "MailItem" Then
        MsgBox "newinspector"
      End If
    End Sub