Office関連

Outlookで返信作成時に件名に自動的に付加される「RE:」を「Re:」にするOutlookマクロ

Answersにあった質問「Outlook2003で、返信する際にタイトルに自動付加される”RE:”を”Re:”にするには?」への回答として書いたコードです。

※ ThisOutlookSessionに下記コードを貼り付けます。
※ Inspectorsオブジェクトの取得はApplicationオブジェクトのStartupイベント(Outlook起動時に実行されるイベント)で行っているので、下記コードを貼り付けた後はOutlookを起動し直す必要があります。

Option Explicit

Private WithEvents myInspectors As Outlook.Inspectors

Private Sub Application_Startup()
  Set myInspectors = Application.Inspectors
End Sub

Private Sub myInspectors_NewInspector(ByVal Inspector As Inspector)
  Dim s As String
 
  If TypeName(Inspector.CurrentItem) = "MailItem" Then
    If Left$(Inspector.CurrentItem.Subject, 3) = "RE:" Then
      s = "Re" & Mid$(Inspector.CurrentItem.Subject, 3)
      Inspector.CurrentItem.Subject = s
    End If
  End If
End Sub

InspectorsオブジェクトのNewInspectorイベントを使って、メールの返信を作成しようとしたときにマクロで件名を変更します。
上記マクロを一部変更すれば「RE:」を削除することもできるし、下記のようにすれば特定の送信者に対する返信のみ件名やCC等を変更することも可能です。
アイデア次第で何かに使えそうですね。

Private Sub myInspectors_NewInspector(ByVal Inspector As Inspector)
  If TypeName(Inspector.CurrentItem) = "MailItem" Then
    If Inspector.CurrentItem.Recipients.Count > 0 Then
      If InStr(Inspector.CurrentItem.Recipients(1).Address, "@hoge.jp") Then
        Inspector.CurrentItem.Subject = "【株式会社hoge宛】" & Inspector.CurrentItem.Subject
        Inspector.CurrentItem.CC = "hogehoge@hoge.jp"
      End If
    End If
  End If
End Sub

Office XP Developer Toolsでリボン対応のCOMアドインを作成する。前のページ

esp@cenetが公開しているPDF公報をダウンロードするVBAマクロ次のページ

関連記事

  1. Office関連

    ガイドを追加するPowerPointマクロ

    PowerPointで図形の位置を調整するときに役立つガイド機能(ガイ…

  2. Office関連

    Excel 2013で駅すぱあとWebサービス APIの「経路探索」を使ってみました。

    「「駅すぱあとWebサービス API無償提供」を利用してみました。」で…

  3. Office関連

    「カレンダーから日付入力」をUserFormに移植してみました。

    前回の記事では、Office 用アプリ「カレンダーから日付入力」と同様…

  4. Office関連

    [PowerShell]iTextSharpを使ってPDFファイルを結合する

    mougにあった質問「2つのPDFファイルを結合するには」の回答用に書…

  5. Office関連

    マクロでリボンを最小化する。

    mougの回答用に書いたコードです。忘れないうちにメモ。・…

  6. Office関連

    Office 2013をインストールしてみました。

    CNET Japanの記事「マイクロソフト、「Office 2013」…

コメント

  1. この記事へのコメントはありません。

  1. この記事へのトラックバックはありません。

Time limit is exhausted. Please reload CAPTCHA.

※本ページはプロモーションが含まれています。

Translate

最近の記事

アーカイブ

PAGE TOP