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

夙愿已清 提交于 2019-12-21 05:27:35

问题


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:


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


来源:https://stackoverflow.com/questions/3674832/fire-an-outlook-2003-macro-when-the-user-creates-a-new-blank-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!