2017-06-28 3 views
0

返信、転送(または基本的に電子メールアイテムへのあらゆる種類の応答を行う)、電子メールの本文を変更したいと思います。私は "送信"イベントでこれを行う方法を知っていますが、私はむしろ変更を見ることができるように構成する前にこれを行うでしょう。 お送り使用:vbaを使用して作成するときOutlookの返信/転送メッセージを変更する

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 

を私は外部の窓(Inspectors.NewInspector)でコンイベントをトリガするが、難易度展望2016のインラインエディタで構成返信(エクスプローラを含み透明な方法を見つけるのを持ってする方法を発見.InlineResponse);

はここで「飛び出し」モーダルウィンドウの応答のために働くものです:

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 

我々はまた、好ましくは透明な単一の関数を使用して、インラインエディタで動作似た何かを行うことができますどのように。

答えて

1

インライン返信の場合、Explorer.InlineReponseイベントを使用できます。このアイテムはパラメータとして渡されます。この動作の

例:

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 
関連する問題