Event Subscriptions in TFS are a very powerful mechanism to get notification about event happening in TFS. You can use the Alerts Explorer, that comes with the TFS Powertools (like I describe in this post), but sometimes it is easier to create subscriptions automatically.
In this post I will show you how to use the TFS API to list subscriptions and to create a subscription.
First create a project which contain references to the following assemblies:
These can be found in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\
Then create a TfsTeamProjectCollection object that contains a reference to your Team Foundation Server. Of course you can also use your own credentials but sometimes it is handier to use a central account which is used for all subscriptions.
To list all subscriptions (for all users) use :
To create a subscription use:
The SubscribeEvent method has a parameter “classification”. This is amongst others used for the display name of the TFS event. Use the xml format like <PT N=\"Display name of event \"/> to make sure the events gets displayed with a name instead of (Unnamed Event)
The Event Types you can use are amongst others:
Check the alerts explorer to view your alerts
Hope this helps!