sysmail_event_log (Transact-SQL)

Contains one row for each Windows or SQL Server message returned by the Database Mail system. (Message in this context refers to a message such as an error message, not an e-mail message.) Configure the Logging Level parameter by using the Configure System Parameters dialog box of the Database Mail Configuration Wizard, or the sysmail_configure_sp stored procedure, to determine which messages are returned.

Column name

Data type

Description

Log_id

int

Identifier of items in the log.

event_type

varchar(11)

The type of notice inserted in the log. Possible values are errors, warnings, informational messages, success messages, and additional internal messages.

log_date

datetime

The date and time the log entry is made.

description

nvarchar(max)

The text of the message being recorded.

process_id

int

The process id of the Database Mail external program. This typically changes each time the Database Mail external program starts.

mailitem_id

int

Identifier of the mail item in the mail queue. NULL if the message is not related to a specific e-mail item.

account_id

int

The account_id of the account related to the event. NULL if the message is not related to a specific account.

last_mod_date

datetime

The date and time of the last modification of the row.

last_mod_user

sysname

The user who last modified the row. For e-mails, this is the user who sent the mail. For messages generated by the Database Mail external program, this is the user context of the program.

Remarks

When troubleshooting Database Mail, search the sysmail_event_log view for events related to e-mail failures. Some messages, such as the failure of the Database Mail external program, are not associated with specific e-mails. To search for errors related to specific e-mails, look up the mailitem_id of the failed e-mail in the sysmail_faileditems view and then search the sysmail_event_log for messages related to that mailitem_id. When an error is returned from sp_send_dbmail, the e-mail is not submitted to the Database Mail system and the error is not displayed in this view.

When individual account delivery attempts fail, Database Mail holds the error messages during retry attempts until the mail item delivery either succeeds or fails. In case of ultimate success, all of the accumulated errors get logged as separate warnings including the account_id. This can cause warnings to appear, even though the e-mail was sent. In case of ultimate delivery failure, all previous warnings get logged as one error message without an account_id, since all accounts have failed.

Permissions

You must be a member of the sysadmin fixed server role or the DatabaseMailUserRole database role to access this view. Members of DatabaseMailUserRole who are not members of the sysadmin role, can only see the events for e-mails that they submit.