Check If sp_send_dbmail Was Successful

前端 未结 2 728
花落未央
花落未央 2021-01-01 09:53

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

相关标签:
2条回答
  • 2021-01-01 10:15

    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())
    
    0 讨论(0)
  • 2021-01-01 10:25

    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.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题