使用vba撰写时更改Outlook答复/转发消息

编程入门 行业动态 更新时间:2024-10-20 21:09:56
本文介绍了使用vba撰写时更改Outlook答复/转发消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在回复,转发(或基本上对电子邮件项目进行任何形式的回复)时,我想更改电子邮件的正文.我知道如何在发送"事件中执行此操作,但是我宁愿在撰写之前执行此操作,以便可以看到更改. 使用发送:

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答复/转发消息

本文发布于:2023-11-25 22:51:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631661.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   vba   Outlook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!