Using Database Mail with SQL Server Agent

SQL Server Agent can use Database Mail to send e-mail messages. To enable and configure Database Mail accounts and profiles use the Database Mail Configuration Wizard.

To use Database Mail to send e-mail messages from SQL Server Agent Mail, you:

  1. Enable Database Mail.
  2. Create a Database Mail account for the SQL Server Agent service account to use.
  3. Create a Database Mail profile for the SQL Server Agent service account to use and add the user to the DatabaseMailUserRole in the msdb database.
  4. Set the profile as the default profile for the msdb database. For more information, see Database Mail Profiles.
  5. Choose Database Mail as the mail system for SQL Server Agent. For more information, see How to: Configure SQL Server Agent Mail to Use Database Mail (SQL Server Management Studio).
  6. Restart SQL Server Agent.

SQL Server Agent caches the profile information for the specified profile. This allows SQL Server Agent to send e-mail in cases where the SQL Server instance becomes unavailable. If the SQL Server instance becomes unavailable, SQL Server Agent starts the Database Mail external program directly to notify the failover operator that the instance is unavailable. Because SQL Server Agent caches profile information, SQL Server Agent does not immediately use new information when the profile changes. After changing the e-mail system, you must restart the SQL Server Agent service for the change to take effect.


To start successfully, SQL Server Agent must be able to connect to SQL Server. Therefore, SQL Server Agent can send notifications when a running instance of SQL Server becomes unavailable, but cannot send notifications if an instance of SQL Server fails to start when the computer starts.

See Also


How to: Create Database Mail Private Profiles (Transact-SQL)


Database Mail

Other Resources

Select Configuration Task (Database Mail)
sp_send_dbmail (Transact-SQL)
sysmail_update_principalprofile_sp (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance