xp_sendmail

(Windows only) Sends a message to the specified recipients. The message is either text or the results of a Transact-SQL query.

Syntax

xp_sendmail recipient [; recipient] . . .
	[, subject]
	[, cc_recipient] . . .
	[, bcc_recipient] . . . 
	[, {query | message}]
	[, attachname]
	[, attach_result = {true | false}]
	[, echo_error = {true | false}]
	[, include_file [, include_file] . . .]
	[, no_column_header = {true | false}]
	[, no_output = {true | false}]
	[, width]
	[, separator]
	[, dbuser]
	[, dbname]
	[, type]
	[, include_query = {true | false}]

Parameters

Examples

Usage

These parameters are related to the results of queries sent in a message when the query parameter is used. They are ignored if the message parameter is used instead: attachname, attach_result, echo_error, no_column_header, no_output, width, separator, dbuser, dname, include_query.

Permissions

By default, only a system administrator can execute xp_sendmail. A system administrator can grant this permission to other users.