在回复,转发(或基本上对电子邮件项目进行任何形式的回复)时,我想更改电子邮件的正文.我知道如何在发送"事件中执行此操作,但是我宁愿在撰写之前执行此操作,以便可以看到更改. 使用发送:
When replying, forwarding (or basically doing any sort of response to an email item), I would like to change the body of the email. I know how to do this on the "send" event, but I would rather do this before composing so I can see change. Using send:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) On Error Resume Next Set RegX = CreateObject("VBScript.RegExp") With RegX .pattern = "[a regular expression that I want to fix in the email body]" .Global = True .MultiLine = True .IgnoreCase = False End With Select Case Item.BodyFormat Case olFormatHTML Item.HTMLBody = RegX.Replace(Item.HTMLBody, "") Case Else 'olFormatPlain, olFormatRichText, lFormatUnspecified? Item.Body = RegX.Replace(Item.Body, "") End Select End Sub我找到了一种在外部窗口中触发compose事件的方法(Inspectors.NewInspector),但是很难找到一种透明的方法,包括在Outlook 2016的内联编辑器中编写的回复(Explorer.InlineResponse);
I found a way to trigger the compose event in the external windows (Inspectors.NewInspector) but have difficulty finding a transparent way that includes a reply composed in the inline editor in Outlook 2016 (Explorer.InlineResponse);
以下是适用于弹出"模态窗口响应的内容:
Here's what works for the "popped out" modal windows response:
Dim myOlApp As New Outlook.Application Public WithEvents myOlInspectors As Outlook.Inspectors Public Sub Initialize_handler() Set myOlInspectors = myOlApp.Inspectors End Sub Private Sub myOlInspectors_NewInspector(ByVal Inspector As Outlook.Inspector) Set Item = Inspector.CurrentItem Set RegX = CreateObject("VBScript.RegExp") With RegX .pattern = "[a regular expression that I want to fix in the email body]" .Global = True .MultiLine = True .IgnoreCase = False End With Select Case Item.BodyFormat Case olFormatHTML Item.HTMLBody = RegX.Replace(Item.HTMLBody, "") Case Else 'olFormatPlain, olFormatRichText, lFormatUnspecified? Item.Body = RegX.Replace(Item.Body, "") End Select End Sub我们该如何做类似的事情,这些事情也可以在内联编辑器中工作,最好使用透明的单个函数.
How can we do something similar that also works in the inline editor, preferably using a transparent single function.
推荐答案对于内联回复,您可以尝试使用Explorer.InlineReponse事件-该项目将作为参数传递.
For the inline replies, you can try to use Explorer.InlineReponse event - the Item will be passed as a parameter.
此示例的作用:
Dim myOlApp As New Outlook.Application Public WithEvents myOlExplorer As Outlook.Explorer Public Sub Initialize_handler() Set myOlExplorer = myOlApp.ActiveExplorer End Sub Private Sub myOlExplorer_InlineResponse(ByVal Item As Object) ' do things to the Item here in the inline response End Sub更多推荐
使用vba撰写时更改Outlook答复/转发消息
发布评论