This project is read-only.

The Email activity can be used to send an email to a given set of users via a specific SMTP server. This can be used when the TFS alerting emails just don’t provide the detail you need. In this example we aim to show the the basic steps that are required to get the activity integrated into a build.

Before you can make use of any of the TFS 2010 community build activities you have to make sure they are available for the build system and on your development PC. Instructions for this process can be found in the ALM Rangers build guide or in the StyleCop page of this wiki. This page assumes the Email activity is available in the developers build process workflow toolbox. Hence we are able to build the workflow shown below

Configuring the activity

Using the Email activity is very straight forward, once it is dropped onto the build process design surface only four properties have to be set (as a minimum) to send an email.

  • MailFrom: a string containing an email address e.g. ""
  • Subject: a string, one including the build number is a good idea e.g. String.Format("An email from build {0}", BuildDetail.BuildNumber)
  • MailTo: a string array of email addresses e.g. New string() {“”}
  • SMTP: a string containing the SMTP server URL e.g. “”

You can of course set other properties such as Body and Attachments to send more useful emails.

Remember it is probably best to pass at least the MailTo: and SMTP: values as build process arguments, as these are very likely to need to be edited for different build.

Running the activity

When you run this, if your build box is not inside your firewallthere is a a good chance you will get SMTP authentication errors. However, these should be easy to resolve given the detailed error report


Assuming the user running the TFS build service has suitable SMTP rights, the you should receive your email when the activity runs.

Last edited Aug 28, 2011 at 10:23 PM by rfennell, version 3


jroth May 30, 2013 at 5:19 PM 
Anybody have insight on attachments? I'm trying to send an email with a folder from the build attached, but I'm getting "Error: Access to the path 'D:\TfsBuild\Builds\9\238\TestResults' is denied.. " It seems logical that this might be a permissions issue with the build's account, but it's got full access to the drop files. Any clues?

Jpmon1 Feb 8, 2013 at 1:35 PM 
Have you tried using '<br />'? The emails are normally in html, so a system new line would do nothing.

vlopez36 Aug 13, 2012 at 9:49 PM 
I have been struggling to what would seem to be a trivial task however, I have not been able to figure it out. I am sending an email using the TfsBuildExtensions.Activities.Communciations.Email activity. I am placing the content of my email in the Body property, however, I cannot figure out how to format my string to contain a new line. I have used "\r\n" in my string.format("{0} \r\n {1}", string1, string2). I have also used string.format("{0} {1} {2}", string1, Environment.Newline, string2). Both ways does not provide a newline. Can anyone explain how I can do this?