Trindaz
Trindaz

Reputation: 17839

Fire an Outlook 2003 macro when the user creates a new blank message

I found events that fire when the user receives a message, or hits the send button, but nothing that fire when the user creates a blank, new email.

Upvotes: 4

Views: 670

Answers (1)

Geoff
Geoff

Reputation: 8850

You should be able to use the NewInspector event. Example:

Public WithEvents myOlInspectors As Outlook.Inspectors

Private Sub Application_Startup()
    Initialize_handler
End Sub

Public Sub Initialize_handler()
    Set myOlInspectors = Application.Inspectors
End Sub

Private Sub myOlInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
    Dim msg As Outlook.MailItem
    If Inspector.CurrentItem.Class = olMail Then
        Set msg = Inspector.CurrentItem

        If msg.Size = 0 Then
            MsgBox "New message"
        End If
    End If
End Sub

Upvotes: 5

Related Questions