Deletes a message from the Microsoft SQL Server inbox. This procedure is used by sp_processmail to process mail in the SQL Server inbox.
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
Any failure except an invalid parameter is logged to the Windows application log.
xp_deletemail deletes the message from the inbox, but does not delete any attachments from the file system. You must delete attachments manually. You can suppress the generation of attachments by setting the suppress_attach parameter for xp_readmail to TRUE. For more information about security issues with attachments, see xp_readmail (Transact-SQL).
xp_deletemail does not keep a log of deleted messages or users who deleted the messages. This may cause auditing problems in an environment where several users have permission to execute xp_deletemail. To minimize this problem, limit permissions for xp_deletemail to members of the sysadmin fixed server role.
The following example retrieves a message ID supplied from xp_findnextmsg, and then uses that message ID to delete a message. The value from xp_findnextmsg is placed in the local variable @message_id.
DECLARE @message_id varchar(255) ; USE master ; EXEC xp_findnextmsg @msg_id = @message_id OUTPUT ; EXEC xp_deletemail @message_id ;