[outlook] [vba] Highlight text in body of incoming emails
http://www.outlookcode.com/threads.aspx?forumid=2&messageid=33313
Sub CustomMailMessageRule(MyMail As Outlook.MailItem)
Dim strID As String
Dim objMail As Outlook.MailItem
strID = MyMail.EntryID
Set objMail = Application.Session.GetItemFromID(strID)
wordToSearch = "Marco"
If InStr(1, objMail.HTMLBody, wordToSearch, vbTextCompare) > 0 Then
strData = objMail.HTMLBody
strData = Replace(strData, wordToSearch, "<FONT style=" & Chr(34) & "BACKGROUND-COLOR: yellow" & Chr(34) & ">" & wordToSearch & "</FONT>")
objMail.HTMLBody = strData
objMail.Save
End If
Set objMail = Nothing
End Sub