配置 SQL Server 代理邮件以使用数据库邮件Configure SQL Server Agent Mail to Use Database Mail
适用于:Applies to: SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
本主题说明如何配置 SQL ServerSQL Server 代理以使用数据库邮件通过 SQL ServerSQL Server 发送 SQL Server Management StudioSQL Server Management Studio中的通知和警报。This topic describes how to configure SQL ServerSQL Server Agent to use Database Mail to send notification and alerts in SQL ServerSQL Server by using SQL Server Management StudioSQL Server Management Studio. 有关如何启用和配置数据库邮件的信息,请参阅 配置数据库邮件。For information on how to enable and configure Database Mail, see Configure Database Mail. 有关使用 Transact-SQLTransact-SQL的示例,请参阅 创建数据库邮件配置文件。For an example using Transact-SQLTransact-SQL, see Create a Database Mail Profile.
开始之前:Before you begin:
开始之前Before You Begin
备注
托管实例上的 SQL 代理始终配置为使用数据库邮件,因此在托管实例上此内容不适用。SQL Agent on Managed Instance is always configured to use Database Mail, so this content is not applicable on Managed Instance. 在托管实例中,需要具有必须调用的配置文件 AzureManagedInstance_dbmail_profile,才能将 SQL 代理与数据库邮件绑定。In Managed Instance you need to have a profile that must be called AzureManagedInstance_dbmail_profile in order to bind SQL Agent with Database Mail.
先决条件Prerequisites
创建供代理服务帐户使用的 数据库邮件帐户 SQL ServerSQL Server 。Create a Database Mail account for the SQL ServerSQL Server Agent service account to use.
创建供 代理服务帐户使用的 数据库邮件配置文件 SQL ServerSQL Server ,并将用户添加到 DatabaseMailUserRole 数据库的 DatabaseMailUserRole 中。Create a Database Mail profile for the SQL ServerSQL Server Agent service account to use and add the user to the DatabaseMailUserRole in the msdb database.
将该配置文件设置为 msdb 数据库的默认配置文件。Set the profile as the default profile for the msdb database.
SecuritySecurity
权限Permissions
创建配置文件帐户和执行存储过程的用户应是 sysadmin 固定服务器角色的成员。The user creating the profiles accounts and executing stored procedures should be a member of the sysadmin fixed server role.
使用 SQL Server Management StudioUsing SQL Server Management Studio
配置 SQL Server 代理邮件以使用数据库邮件To configure SQL Server Agent to use Database Mail
在对象资源管理器中,展开 SQL ServerSQL Server 实例。In Object Explorer, expand a SQL ServerSQL Server instance.
右键单击“SQL Server 代理”,然后单击“属性”。Right-click SQL Server Agent, and then click Properties.
单击 “警报系统”。Click Alert System.
选择 “启用邮件配置文件”。Select Enable Mail Profile.
在 “邮件系统” 列表中,选择 “数据库邮件”。In the Mail system list, select Database Mail.
在 “邮件配置文件列表” 中,为数据库邮件选择一个邮件配置文件。In the Mail profile list, select a mail profile for Database Mail.
重启 SQL Server 代理。Restart SQL Server Agent .
后续任务Follow-up Tasks
需要执行下列任务以完成对发送警报和通知的代理配置。The following tasks are necessary to complete the configuration of Agent to send alerts and notifications.
-
可以配置警报,将特定数据库事件或操作系统情况通知操作员。Alerts can be configured to notify an operator of a particular database event or operating system condition.
-
操作员是可以接收电子通知的人员或组的别名Operators are aliases for people or groups that can receive electronic notification