How to use SQL Mail (Transact-SQL)

How to Install SQL Server 2000

How To

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, SQLMAP70.DLL, which is installed with Microsoft® SQL Server™ 2000.

To process e-mail messages manually

  1. In SQL Query Analyzer, start a SQL Server Mail client session by executing xp_startmail.

  2. To find the ID of the next unread message in the mail box, execute xp_findnextmsg.

  3. 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.

  4. To delete a message, execute xp_deletemail (using a specific message ID).

  5. To send a message or a query result set to specified recipients, execute xp_sendmail (with the query in the message body).

  6. Stop the SQL Server Mail client session by executing xp_stopmail.

To process multiple e-mail messages as a scheduled job

  1. In SQL Query Analyzer, start a SQL Server Mail client session by executing xp_startmail.

  2. Execute sp_processmail to find, read, respond to, and delete multiple messages.

  3. Stop the SQL Server Mail client session by executing xp_stopmail.

See Also

sp_processmail

xp_sendmail

xp_deletemail

xp_startmail

xp_findnextmsg

xp_stopmail

xp_readmail