[ @profile_name = ] 'profilename' ,
[ @id = ] id ,
[ @name = ] 'name' ,
[ @subject = ] 'subject' ,
[ @body = ] 'message' ,
[ @file_attachments = ] 'attachment'
[ @mail_database = ] 'mail_host_database'
@profile_name = ] ' profilename '
The name of the Database Mail profile to use to send the message.
profilename is . If nvarchar(128) profilename is not specified, the default Database Mail profile is used.
@id = ] id
The identifier for the operator to send the message to.
id is , with a default of NULL. One of int id or name must be specified.
@name = ] ' name '
The name of the operator to send the message to.
name is , with a default of NULL. One of nvarchar(128) id or name must be specified.
An e-mail address must be defined for the operator before they can receive messages.
@subject = ] ' subject '
The subject for the e-mail message.
subject is with no default. nvarchar(256)
@body = ] ' message '
The body of the e-mail message.
message is with no default. nvarchar(max)
@file_attachments = ] ' attachment '
The name of a file to attach to the e-mail message.
attachment is , with no default. nvarchar(512)
@mail_database = ] ' mail_host_database '
Specifies the name of the mail host database.
mail_host_database is . If no nvarchar(128) mail_host_database is specified, the msdb database is used by default.
0 (success) or 1 (failure)
Sends the message specified to the e-mail address of the operator specified. If the operator has no e-mail address configured, returns an error.
Database Mail and a mail host database must be configured before a notification can be sent to an operator.
By default, members of the
sysadmin fixed server role can execute this stored procedure. Other users must be granted one of the following SQL Server Agent fixed database roles in the msdb database:
For details about the permissions of these roles, see
. SQL Server Agent Fixed Database Roles
The following example sends a notification e-mail to the operator
François Ajenstat using the AdventureWorks Administrator Database Mail profile. The subject of the e-mail is Test Notification. The e-mail message contains the sentence, "This is a test of notification via e-mail."
USE msdb ;
@profile_name = N'AdventureWorks Administrator',
@name = N'François Ajenstat',
@subject = N'Test Notification',
@body = N'This is a test of notification via e-mail.' ;
Did you find this helpful?
( 1500 characters remaining)
Thank you for your feedback