An outgoing message can consist of text or the formatted results of a query or batch of queries. You can send a message directly through isql from either a stored procedure or a trigger that uses the xp_sendmail ESP.
Keep the following concepts in mind when managing outgoing messages:
To send query results, input the query, or a stored procedure containing the query, to xp_sendmail. The query results are sent to the recipients of the message.
When the message consists of query results, you can specify whether you want the results to be sent in the body of the e-mail message or as an attachment.
When the message consists of text, use the message parameter to xp_sendmail.
When the message consists of the results of a query, use the query parameter, and pass the quoted text of the query or the quoted execute command with its stored procedure name.
For syntax and parameters for xp_sendmail, see the Adaptive Server Reference Manual.