I am looking for a way to check if a particular e-mails queued using sp_send_dbmail
are eventually successful sent from our Exchange server. I\'ve looked at th
sysmail_faileditems
will only get you the list of failed emails. If you need to see a list of successfull emails you need to use sysmail_mailitems
.
Use the below query to get details for all emails sent the same date:
SELECT * FROM msdb..sysmail_mailitems WHERE sent_date > DATEADD(DAY, -1,GETDATE())
And here is the complete query to get all the failed emails from the past 24 hours:
SELECT items.subject ,
items.recipients ,
items.copy_recipients ,
items.blind_copy_recipients ,
items.last_mod_date ,
l.description
FROM msdb.dbo.sysmail_faileditems AS items
LEFT OUTER JOIN msdb.dbo.sysmail_event_log AS l
ON items.mailitem_id = l.mailitem_id
WHERE items.last_mod_date > DATEADD(DAY, -1,GETDATE())
This link from Microsoft seems to be useful - How to: Check the Status of E-Mail Messages Sent With Database Mail (Transact-SQL). See also related topics on Database Mail Logging and Auditing, Troubleshooting Database Mail.