Quick Scan Report – Failed Database Mail

If your SQL Server is attempting to send database mail, and the send process fails, it may not be entirely obvious that the mail failed.

You can use the following query to see what mail has been sent, or has been attempted to be sent from your SQL Server;


SELECT TOP 100 * 
 FROM msdb.dbo.sysmail_allitems WITH (NOLOCK)
 order by send_request_date desc;

The Quick Scan Report detects Failed Database Mail.

After you have fixed the errors causing database mail to fail, you can clean up the log and the history of the mail items with the following commands. The first one cleans the log, and the second one cleans the history of mailitems.


EXECUTE msdb.dbo.sysmail_delete_log_sp;



DECLARE @GETDATE datetime;

SET @GETDATE = GETDATE();  

EXECUTE msdb.dbo.sysmail_delete_mailitems_sp 
@sent_before = @GETDATE;  


Related Links:


Enroll Today!
SteveStedman5
SteveStedman5
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!