How to Auto Highlight All Occurrences of Specific Words for Each Incoming Email in Outlook

Some users want to let Outlook search each incoming email for all occurrences of specific words and then highlight them automatically. Though Outlook doesn’t offer such a native function, it still can be realized via the VBA code exposed in this post.

In order to quickly figure out the important text in long and tedious emails, many users would like to make the specific words highlighted automatically. That is to say, Outlook should auto search every incoming email and highlight the specific words in this mail. Without any doubt, Outlook doesn’t provide such a feature. So, to achieve it, you have to utilize other means, such as the following one, which is using VBA.

Auto Highlight All Occurrences of Specific Words for Each Incoming Email in Outlook

Auto Highlight All Occurrences of Specific Words for Each Incoming Email

  1. To start with, launch your Outlook program.
  2. Then in the Outlook main screen, you ought to press “Alt + F11” keys to get access to the VBA editor.
  3. After that, in the emerging “Microsoft Visual Basic for Applications” window, you ought to open a module that isn’t being used.
  4. Subsequently, you can copy the following VBA code into this module.
Sub AutoHighlight_AllOccurencesOfSpecificWords(objMail As Outlook.MailItem)
    Dim strWord As String
    Dim strHTMLBody As String
 
    strHTMLBody = objMail.HTMLBody
 
    'Change the word as per your wishes
    strWord = "DataNumen"
 
    'If find the specific word
    If InStr(strHTMLBody, strWord) > 0 Then
       'Highlight it in yellow color
       strHTMLBody = Replace(strHTMLBody, strWord, "<font style=" & Chr(34) & "background-color: yellow" & Chr(34) & ">" & strWord & "</font>")
 
       objMail.HTMLBody = strHTMLBody
    End If
 
    'Add more words to be highlighted as per your needs
    strWord = "Outlook"
 
    If InStr(strHTMLBody, strWord) > 0 Then
       strHTMLBody = Replace(strHTMLBody, strWord, "<font style=" & Chr(34) & "background-color: yellow" & Chr(34) & ">" & strWord & "</font>")
 
       objMail.HTMLBody = strHTMLBody
    End If
 
    objMail.Save
End Sub

VBA Code - Auto Highlight All Occurrences of Specific Words for Each Incoming Email

  1. Later you’d be required to create a new rule to run this script. Just follow the steps below:
  • Firstly, exit the VBA editor as usual.
  • Then head to “File” menu and hit the “Manage Rules & Alerts” button.
  • In the new popup “Rules and Alerts” dialog box, hit “New Rule” button.
  • Next in the “Rules Wizard” dialog box, select the “Apply rule on messages I receive” and hit “Next”.
  • And then you could specify the rule conditions as per your needs. Or if no condition, you can directly click on “Next” > “Yes”.
  • After that, you ought to choose the “Rule a script” action.
  • Later hit the “a script” link in “Step 2” box.
  • In the popup small window, choose the previously added macro.
  • Next hit “OK” and “Next”.Run Script
  • Then set the exceptions at will and click on “Next”.
  • In the final “Rules Wizard” screen, specify a name for this rule and click on the “Finish” button to save this rule.
  1. From now on, Outlook will automatically search each incoming email for the predefined words and highlight them in yellow color, shown as the following screenshot:Highlighted Words in Incoming Email

Make PST Backups at Regular Intervals

Although Outlook has satisfied a host of our needs, it still cannot get rid of errors and corruption. It’s vulnerable to various factors, like improper shutdown, virus infection, hardware malfunctions and so on. Thus, it is essential for you to make regular Outlook PST backups, so that you can retrieve PST data via backups with effortless ease. If backups fail, you can try the in-built tool – Scanpst. Also, there is much similar repair software in the market, like DataNumen Outlook Repair. This tool has shouldered over its peers due to its high PST recovery rate.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql fix and outlook repair software products. For more information visit www.datanumen.com

One response to “How to Auto Highlight All Occurrences of Specific Words for Each Incoming Email in Outlook”

Leave a Reply

Your email address will not be published. Required fields are marked *