meaning of the values of sent_status on msdb.dbo.sysmail_mailitems

心已入冬 提交于 2019-12-09 12:56:06

问题


I am sending emails from SQL Server, and need to map the values of the sent_status column on the msdb.dbo.sysmail_mailitems table to something more descriptive.

So far I have identified two values:

  • 1 = 'Sent'
  • 2 = 'Failed'

Are there any more possible values, and if so what do they represent?


回答1:


sent_status, --0 new, not sent, 1 sent, 2 failure or 3 retry.



回答2:


On the MSDN page for the related msdb.dbo.sysmail_allitems table, the description for sent_status says:

The status of the mail. Possible values are:

sent - The mail was sent.

unsent - Database mail is still attempting to send the message.

retrying - Database Mail failed to send the message but is attempting to send it again.

failed - Database mail was unable to send the message.

Connecting the two views together as follows:

SELECT DISTINCT mi.sent_status, ai.sent_status 
FROM 
    msdb.dbo.sysmail_allitems ai
     FULL OUTER JOIN 
    msdb.dbo.sysmail_mailitems mi ON 
        ai.mailitem_id = mi.mailitem_id

Will yield a relationship, which can be expressed with the following CASE statement:

SELECT 
    CASE sent_status
        WHEN 0 THEN 'Unsent'
        WHEN 1 THEN 'Sent'
        WHEN 2 THEN 'Failed'
        WHEN 3 THEN 'Retrying'
        END AS sent_status_desc
FROM msdb..sysmail_mailitems


来源:https://stackoverflow.com/questions/26995264/meaning-of-the-values-of-sent-status-on-msdb-dbo-sysmail-mailitems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!