Share via


SMTP Delivery Protocol

The Simple Mail Transfer Protocol (SMTP) delivery protocol creates and routes notification messages for delivery by an SMTP service, such as that provided by Microsoft Exchange or Internet Information Services. If you want to use the SMTP delivery protocol to deliver notifications from a particular notification class, you define the SMTP delivery protocol as part of the notification class in the application definition.

Important

The SMTP service is required for using the SMTP delivery protocol, but it is not installed with Windows Vista. To use the SMTP delivery protocol on Windows Vista, you must separately install an SMTP service.

Defining an SMTP Delivery Protocol

A protocol definition consists of a name and values for any custom fields. The SMTP delivery protocol uses the following values and fields:

  • The ProtocolName value (required) must be SMTP.
  • Define the following fields, in the following order, for the delivery protocol:
    • Subject (required) specifies the expression that represents the subject line to display in the e-mail.
    • From (required) specifies the sending e-mail address to display in the e-mail.
    • To (required) must specify the address of the target device. This field must be blank for a notification class that is providing multicast notifications.
    • Priority (optional) specifies the e-mail message priority. For Microsoft Exchange, the available values are Low, Normal, or High. The notification priority default is Normal if no other value is specified.
    • BodyFormat (optional) takes either "text" or "html" as its value, depending on what the intended format is for the notification data that is provided by the content formatter. The notification format default is text if no value is specified.

In Transact-SQL syntax, string constants must be enclosed in quotation marks. Therefore, if you use a string in a delivery protocol field, you must enclose it in single quotation marks, such as 'myString'. If the string is Unicode, also start the string with an N, such as N'myString'.

Example Definition of SMTP Delivery Protocol

The following example shows how to define an SMTP delivery protocol for a notification class:

<Protocols>
    <Protocol>
        <ProtocolName>SMTP</ProtocolName>
        <Fields>
            <Field>
                <FieldName>Subject</FieldName>
                <SqlExpression>
                'The price of ' + StockSymbol
                + ' is now ' + StockPrice
                </SqlExpression>
            </Field>
            <Field>
                <FieldName>From</FieldName>
                <SqlExpression>
                N'stockquotes@microsoft.com'
                </SqlExpression>
            </Field>
            <Field>
                <FieldName>To</FieldName>
                <SqlExpression>DeviceAddress</SqlExpression>
            </Field>
            <Field>
                <FieldName>Priority</FieldName>
                <SqlExpression>N'Normal'</SqlExpression>
            </Field>
            <Field>
                <FieldName>BodyFormat</FieldName>
                <SqlExpression>N'html'</SqlExpression>
            </Field>
            <Field>
        </Fields>
        <ProtocolExecutionSettings>
            ...
        </ProtocolExecutionSettings>
    </Protocol>
</Protocols>

All the fields in this example use Transact-SQL expressions to obtain their values:

  • The Subject field uses a combination of strings and notification field references (StockSymbol and StockPrice) to customize the subject line for each notification.
  • The To field obtains its value from the DeviceAddress field for the subscriber device. For a list of available fields, see SqlExpression Element for Protocol/Fields/Field (ADF).
  • The From, Priority, and BodyFormat fields are strings that are the same for all notifications that are sent by using the delivery protocol.

Fields can also obtain their values directly from notification fields. For more information, see FieldReference Element (ADF).

Defining a Delivery Channel for the SMTP Delivery Protocol

To use the SMTP delivery protocol to distribute notifications, you must also define a delivery channel that uses the SMTP delivery protocol. Multiple notification classes from multiple applications can use the same SMTP delivery channel.

Important

Because of the SMTP implementation that is used by the Microsoft .NET Framework, you can define only one delivery channel using the SMTP delivery protocol per instance. If you define two SMTP delivery channels, notifications might go to the wrong SMTP servers.

For more information, see Defining an SMTP Delivery Channel.

See Also

Concepts

File Delivery Protocol
Developing a Custom Delivery Protocol

Other Resources

Configuring Delivery Protocols
Defining Notification Classes
Protocol Element (ADF)

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

14 April 2006

New content:
  • Added note that SMTP service is not installed with Windows Vista.
  • Added description of sample code.