How to use SQL Mail (Transact-SQL)
SQL Mail uses several extended stored procedures that are necessary for mail enabling. These extended stored procedures are included in a dynamic-link library, SQLMAP60.DLL, which is installed with Microsoft® SQL Server™.
To process e-mail messages manually
- In SQL Server Query Analyzer, start a SQL Server Mail client session by executing xp_startmail.
- To find the ID of the next unread message in the mail box, execute xp_findnextmsg.
- To read a message or attachment, execute xp_readmail (using a specific message ID), and use the output variable in a SELECT statement to display the message in the result pane.
- To delete a message, execute xp_deletemail (using a specific message ID).
- To send a message or a query result set to specified recipients, execute xp_sendmail (with the query in the message body).
- Stop the SQL Server Mail client session by executing xp_stopmail.
To process multiple e-mail messages as a scheduled job
- In SQL Server Query Analyzer, start a SQL Server Mail client session by executing xp_startmail.
- Execute sp_processmail to find, read, respond to, and delete multiple messages.
- Stop the SQL Server Mail client session by executing xp_stopmail.
See Also
(c) 1988-98 Microsoft Corporation. All Rights Reserved.