I want to develop a Microsoft Outlook add-in that highlights links in Emails. I found this example for a add in that highlights order numbers and displays a popup when clicking on it. The Code “responsible” for that is this regex in the manifest:
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" ItemType="Message" />
<Rule xsi:type="ItemHasRegularExpressionMatch" RegExName="OrderNumber" RegExValue="CO-d{9}" PropertyName="BodyAsPlaintext"/>
</Rule>
I basically want the same for any link in an email. I thought I could just use a regex for a link, bit somehow it is not working. Here is my current code:
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" ItemType="Message" />
<Rule xsi:type="ItemHasRegularExpressionMatch" RegExName="Link" RegExValue="(https?://(?:www.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9].[^s]{2,}|www.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9].[^s]{2,}|https?://(?:www.|(?!www))[a-zA-Z0-9]+.[^s]{2,}|www.[a-zA-Z0-9]+.[^s]{2,})" PropertyName="BodyAsPlaintext"/>
</Rule>
My goal is to prevent the default behaviour which is opening the link and displaying the popup instead. Has anyone figured this out?
1