Delving Deeper into Notification Services - Creating a Delivery Channel
(Page 2 of 4 )
A file delivery channel named StockWatchFileDeliveryChannel and an email delivery channel named StockWatchEmailDeliveryChannel are created in the CreateDeliveryChannel()method of Example 18-1. The code follows:
private static void CreateDeliveryChannel()
{
DeliveryChannelArgument dca;
// add file delivery channel
DeliveryChannel dcFile =
new DeliveryChannel(nsi, "StockWatchFileDeliveryChannel");
dcFile.ProtocolName = "File";
dca = new DeliveryChannelArgument(dcFile, "FileName");
dca.Value = baseDirectoryPath + @"\Notifications\FileNotifications.txt";
dcFile.DeliveryChannelArguments.Add(dca);
nsi.DeliveryChannels.Add(dcFile);
Console.WriteLine("Added delivery channel: " + dcFile.Name);
// add email delivery channel
DeliveryChannel dcEmail =
new DeliveryChannel(nsi, "StockWatchEmailDeliveryChannel");
dcEmail.ProtocolName = "SMTP";
nsi.DeliveryChannels.Add(dcEmail);
Console.WriteLine("Added delivery channel: " + dcEmail.Name);
}
You have to add at least one delivery channel to a Notification Services instance before creating it. TheProtocolNameproperty of theDeliveryChannel object must be set toSMTP,File, or the name of a custom delivery protocol.
The NMO classes used to manage delivery channels are described in Table 18-3.
Table 18-3. NMO classes for managing delivery channels
| Delivery channel | Description |
| DeliveryChannel | Represents a delivery channel. |
| DeliveryChannelArgument | Represents a name-value pair specifying delivery channel configuration and authentication information for the delivery service. |
| DeliveryChannelArgumentCollection | Represents a collection of delivery channel arguments asDelivery-ChannelArgumentobjects. TheDeliveryChannelArguments property of theDeliveryChannelclass returns the delivery channel arguments for the delivery channel. |
| DeliveryChannelCollection | Represents a collection of delivery channels asDeliveryChannel objects. TheDeliveryChannelsproperty of theInstanceclass returns the delivery channels for the Notification Services instance. |
Next: Creating an Event Class >>
More MS SQL Server Articles
More By O'Reilly Media
|
This article is excerpted from chapter 18 of the book Programming SQL Server 2005, written by Bill Hamilton (O'Reilly, 2006; ISBN: 0596004796). Check it out today at your favorite bookstore. Buy this book now.
|
|