Making your Outlook Add-in contextual

In this article I will demonstrate how to make an Outlook Add-in appear only on certain words in an email.

Introduction

In previous articles we have looked at creating an Outlook Add-in and then how it works. Other than only being a sample app, this Add-in now appears on every email. What would be much more user friendly would be to make sure it only appear contextually, say if a word was in the body of an email for example.

In this article we are going to make the example Add-in only appear in emails with the word “Websockets” in it.

The XML Manifest

If we look at the properties of the napa dev console (the spanner on the left)

n1

We can see that there are a number of options for the “read form”

n2

At the top we can see “Edit read form XML” which is the manifest for the application. What we are looking at above is the visual representation of that XML file.

n3

Looking at the Use regular expression activation rules to show a mail add-in in Outlook article we can find an example of a rule which check through the body of the email as plain text

<Rule xsi:type=”ItemHasRegularExpressionMatch”
PropertyName=”BodyAsPlaintext”
RegExName=”TickerSymbols”
RegExValue=”\b(NYSE|NASDAQ|AMEX):\s*[A-Za-z]+\b”/>

But in my example I am going to look for the words Websockets and make sure that ignorecase is true (websockets or WebSOckEts would work)

<Rule xsi:type=”ItemHasRegularExpressionMatch”
PropertyName=”BodyAsPlaintext”
IgnoreCase=”true”
RegExName=”Websockets”
RegExValue=”websockets”/>

I inserted the XML snippet above *inside* of the XML example code shown

n4

and if you look at the non-XML version of the Read Form properties, you can see how this change is reflected

n5

Running the application

If we look at the sample sample email as before – we will now no longer see any Marky Websockets Add-in

n6

But if we find a new email with the word websockets inside it – we can see that it is contextually highlighted

n7

Clicking on the word itself then triggers the sample Add-in to run

n8

Conclusion

In this article we have looked at how we can simply add an Add-in contextually to the body of an email.

 

 

 

Advertisements

3 thoughts on “Making your Outlook Add-in contextual

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s