Search This Blog

Wednesday, January 23, 2013

Database Mail Views (SQL Server)

SQL Server > Catalog Views > Database Mail

These views are located in the msdb database.

Database Mail has views for displaying Database Mail e-mails information such as status of e-mails, any messages received and errors logged by Database Mail.

sysmail_allitems

Contains one row for each message processed by Database Mail.

Important columns


Name
Description
mailitem_id
Identifier of the mail item in the mail queue.
profile_id
The identifier of the profile used to send the message.
recipients
The e-mail addresses of the message recipients.
subject
The subject line of the message.
body
The body of the message.
sent_status
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.
sent_date
The date and time that the message was sent.

sysmail_faileditems

Contains information about  messages were not successfully sent.
Has the same colums as but sent_status value is always failed.
To view the reason for the failure see onformation in the sysmail_event_log view.

sysmail_event_log

Contains one row for each message returned by the Database Mail system.
When troubleshooting Database Mail, search in sysmail_event_log view for events related to e-mail failures.

Important columns:


event_type
Errors, warnings, informational messages, success messages
log_date
The date and time the log entry is made.
description
The text of the message being recorded.
mailitem_id
Identifier of the mail item in the mail queue.