Convert RTF Messages to Plain Text Format

Last reviewed on May 8, 2014   —  No comments yet

One of the suggested solutions to the potential RTF vulnerability described in Microsoft released Security Advisory (2953095): Vulnerability in Microsoft Word Could Allow Remote Code Execution is to set Outlook to read all mail in plain text format.

Rather than setting all messages to plain text format, you can use an ItemAdd macro to convert only RTF messages to plain text or HTML format as they arrive in your Inbox. If you prefer to use a Run a Script rule, the same basic code will work but you'll need to create a rule to run it.

In addition to changing the message format, I'm adding a category called "Was RTF" so I know the message was converted from RTF format by the macro.

Macro to Convert RTF Messages to Plain Text Format

Option Explicit
Private WithEvents Items As Outlook.Items
 
Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace
  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub
 


Private Sub Items_ItemAdd(ByVal Item As Object)

If Item.MessageClass <> "IPM.Note" Then
  Exit Sub
End If

  If Item.BodyFormat = olFormatRichText Then

    Item.BodyFormat = olFormatPlain ' or olFormatHTML
    Item.Categories = "Was RTF"
    Item.Save
  Else
 End If
End Sub

Run a Script rule

For a run a script rule, change the first line of the macro then create a rule to check every message that arrives. As one of the conditions, choose Uses the From name, and select Note from the Applications Forms list.

Sub CovertRTFtoPlain(Item As Outlook.MailItem)

  If Item.BodyFormat = olFormatRichText Then

    Item.BodyFormat = olFormatPlain ' or olFormatHTML
    Item.Categories = "Was RTF"
    Item.Save
  Else
 End If
End Sub

More information on configuring a run a script rule is here: Outlook's Rules and Alerts: Run a Script

How to use Macros

First: You will need macro security set to low during testing.

To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To use the macro code in ThisOutlookSession:

  1. Expand Project1 and double click on ThisOutlookSession.
  2. Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)

More information as well as screenshots are at How to use the VBA Editor

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

Leave a Reply

If the Post Coment button disappears, press your Tab key.