One the more welcomed enhancements of SQL Server 2005 Notification Services was the new Microsoft.SqlServer.Management.Nmo namespace. The namespace provides classes that may be used develop and administer SSNS instances and applications.
For example, the following C# console application may be used to iterate through each SSNS instance of a SQL Server 2005 instance, printing its name to the console window. If you'd like to try this code for yourself, don't forget to add a reference to the microsoft.sqlserver.smo.dll in your Visual Studio 2005 project.
static void Main(string args)
//SQL Server instance
string myServer = @"CEDAR\SS2005";
Server server = new Server(myServer);
//Notification Services object
NotificationServices ns = server.NotificationServices;
//enumerate through each instances
for (int cnt = 0; cnt < ns.Instances.Count; cnt++)
string nam = ns.Instances[cnt].Name;
//pause to view the output
Console.WriteLine("Press the Enter key to continue");
Although the quickest way to create a SSNS instance and application is still to craft an XML-based Instance Configuration File (ICF) and Application Definition File (ADF), it's nice to have the nmo namespace available to automate some tasks as needed.