Team Foundation Server 2010 can create custom alerts that fit almost any set of criteria you can come up with, but the emails that it generates are pretty generic, though informative. Wouldn’t it be great if you were able to customize the information that was contained in them and maybe even spice them up a little bit with corporate branding? With just a little bit of work, you can have these looking much better.
On your server that is housing the TFS 2010 Application Tier, all of the e-mail templates are contained in the same folder where TFS Job Agent was installed. In my case, the files are located at:
C:\Program Files\Microsoft Team Foundation Server 2010\Application Tier\TFSJobAgent\Transforms
There are many different templates here for different kinds of alerts, but for this example, we’ll concentrate on the normal Work Item alerts. These are the ones that are used for alerts relating to Work Item changes, reassignment, and status updates, but there are others there for build alerts, checkins and the like. These two files are:
- WorkItemChangedEvent.xsl — This is the HTML version of the alert that is usually sent when the alert is triggered.
- WorkItemChangedEvent.plaintextXsl — This is the plaintext version of the alert.
Opening these files, you will see pretty standard XSL used the transform the TFS data into the alert e-mail. For this example, let’s just add a header and create a link to the style sheet that I use for my custom process guidance to make sure the branding is identical across all communication with the end-users of the TFS instance.
So let’s modify the header and body of the e-mail to make things a bit more friendly…
<?xml version=“1.0” encoding=“UTF-8”?>
<xsl:stylesheet xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” version=”1.0″>
<!– Common TeamSystem elements –>
<!– Pull in the command style settings –>
<!– Link to the Company TFS Style Sheet –>
<link href=“http://processguidance.Company.com/Style/Content.css” type=“text/css” rel=“stylesheet” />
<!– Company Email header –>
<img height=“17” src=“http://processguidance.Company.com/Images/EmailHeaderBar.png” />
<img alt=“Company Name” height=“40” src=“http://processguidance.Company.com/Images/Company_logo.gif” width=“270” />
<!– End Company Header–>
Now that we have some really basic markup in the header of the e-mail, our correspondence with the end-user will look much better. Of course, you can dig a bit deeper to change the fields displayed in the alerts or add a footer. Just make sure that you always have a backup of the original file and test test test!