6

Creating Body-content-triggered rules for HTML-formatted messages

I receive an automated set of emails which are HTML formatted. Certain emails I want to treat differently based on a part of the content. The content involves recognizing a specific HTML-anchor in the body.

How do I express such a rule?

What I have tried:
I have saved a representative email as an HTML file and then found the anchor in that file. I then used the anchor title in my rule. I also tried using the entire HTML anchor (since the email is auto-generated, the format will always be exactly the same). Obviously, neither worked because here I am asking for help.

I am using a MS Outlook 2016 client.

Tevya
  • 161

2 Answers2

2

For simplicity and for users who don't want to deal with VBA the following is an easy workaround.

Most HTML emails have formatting applied to the text in source. So if there is a URL in the text you are searching your rule won't run as expected. So before you create a rule I suggest you go to File > Options > Trust Center > Trust Center Settings > E-mail Security and then enable the option "Read all standard mail in plain text"

Trust Center

After you do that look at the email you are interested in and use the text you want to use to create the rule. This will contain the links how outlook see it and your rule should too.

salamay
  • 21
1

This is the common pattern for that:

  1. Create a VBA macro that finds required tags/anchors/... in MailItem.HTMLBody. If found, it has to set either some UserProperties or Categories to mark this email as containing required HTML source.
  2. Create a new helper rule that has additional conditions to inspecting HTML (if needed) or just without any conditions. Set the action for this rule to run a script and select the script from step 1. Do not select stop processing more rules. Move this rule to the top of your rule list.
  3. Create a rule that does what you want with messages containing required HTML tags/anchors/...: move to folder, forward, etc. Set this rule's condition to check for a category or user property set by the VBA from step 1.
thims
  • 9,361