配置 SQL Server 代理邮件以使用数据库邮件Configure SQL Server Agent Mail to Use Database Mail

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL 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

备注

托管实例上的 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

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

    可以配置警报,将特定数据库事件或操作系统情况通知操作员。Alerts can be configured to notify an operator of a particular database event or operating system condition.

  • 运算符Operators

    操作员是可以接收电子通知的人员或组的别名Operators are aliases for people or groups that can receive electronic notification