0

当我使用 Outlook 2013 回复文本或 rtf 邮件时,我想编写一个更改邮件格式的脚本。有一些开始。我使用了MS 开发中心中描述的回复事件。不幸的是,这个例子并没有像我期望的那样工作。为了测试,我输入了一个简单的消息框,单击回复按钮后应该会弹出该消息框。我从来没有看到那个消息框。我做错什么了?

Public WithEvents myItem As MailItem 

Sub Initialize_Handler() 

    Set myItem = Application.ActiveInspector.CurrentItem 

End Sub 


Private Sub myItem_Reply(ByVal Response As Object, Cancel As Boolean) 

    'Set Response.SaveSentMessageFolder = myItem.Parent
    MsgBox "I never see this message box :("

End Sub
4

3 回答 3

2

您是否在 Explorer 或 Inspector 中单击回复?只有在检查器中单击回复按钮时,您的代码才会运行。

于 2014-06-04T05:31:45.593 回答
1

要使用 Microsoft 推广的方法,您需要在 ThisOutlookSession 中使用此代码。如果事件代码不在此特殊类模块中,则需要它。

Private Sub Application_Startup()
    Initialize_handler
End Sub

如果所有代码都在 ThisOutookSession 中,则可以使用 Max 的答案中描述的方法,其中代码在 Application_Startup 而不是 Initialize_handler 中。

于 2017-07-11T16:22:56.110 回答
0

你必须把它放到“ThisOutlookSession”中——只有在那里它才会起作用!

Option Explicit
Private WithEvents objInspectors As Outlook.Inspectors

Private Sub Application_Startup()
   Set objInspectors = Outlook.Inspectors
end Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If Inspector.CurrentItem.Class = olMail Then
            Set newItem = Inspector.CurrentItem
    End If
    Set Inspector = Nothing
End Sub

Public Sub newItem_Open(Cancel As Boolean)
   newItem.BodyFormat = olFormatHTML
   If newItem.Sent = True Then Exit Sub
End Sub

这将适用于任何新的邮件项目,我不知道如何使这项工作仅用于回复。您可以检查主题,如果已经有主题,它将是一个回复。

于 2014-06-05T06:59:06.367 回答