failmail

Snippet Name: failmail

Tags: helpful,scriptgeneration

Created Date: Oct 1 2021 8:05AM
Last Modified Date: Apr 1 2022 11:22AM

–desc: list of recent failed emails in database mail

Dependencies: none-standalone code

default description

Sample Output:

 
 {C}
 
 --desc: list of recent failed emails in database mail
 
 SELECT top 100
 
 mail.send_request_date As SentDate,
 
 sent_status As Reason,
 
   err.[description],
 
   mail.*
 
 FROM [msdb].[dbo].[sysmail_allitems] mail 
 
   inner join [msdb].[dbo].[sysmail_event_log] err
 
     ON err.mailitem_id = mail.mailitem_id
 
 WHERE mail.sent_status <> 'sent'
 
     order by mailitem_id desc
 
 

Leave a Reply