Fire an Outlook 2003 macro when the user creates a

2019-03-30 19:29发布

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.

1条回答
唯我独甜
2楼-- · 2019-03-30 20:02

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
查看更多
登录 后发表回答