SQL Server Express版中的数据库邮件配置

In this article, I am going to explain step by step process to perform Database Mail configuration in SQL Server Express edition using the T-SQL script. As we know, SQL Server Express edition does not provide the SQL Server Agent Services; hence we cannot perform Database Mail configuration or SQL Jobs or maintenance plans using SQL Server Management Studio. To configure the Database Mail feature in the SQL Server Express edition, we must use CLR integration or using stored procedures within the MSDB database.

在本文中,我将逐步说明使用T-SQL脚本在SQL Server Express版中执行数据库邮件配置的过程。 众所周知,SQL Server Express版本不提供SQL Server代理服务。 因此,我们无法使用SQL Server Management Studio执行数据库邮件配置或SQL作业或维护计划。 要在SQL Server Express版中配置数据库邮件功能,我们必须使用CLR集成或在MSDB数据库中使用存储过程。

SQL Server数据库邮件服务和存储过程 (SQL Server Database Mail service and stored procedure)

To perform the Database Mail configuration, we are going to use the following stored procedures of the MSDB database of SQL Server Express edition:

要执行数据库邮件配置,我们将使用SQL Server Express版的MSDB数据库的以下存储过程:

msdb.dbo.sysmail_add_profile_sp (msdb.dbo.sysmail_add_profile_sp )

This stored procedure adds a database mail profile in SQL Server. Following is the syntax of the stored procedure:

此存储过程在SQL Server中添加数据库邮件配置文件。 以下是存储过程的语法:

Execute sysmail_add_profile_sp 
@profile_name =  'DBMailprofile_name'  
    , @description =  'description'

It uses two input parameters:

它使用两个输入参数:

  1. @Profile_name: The value of this parameter is the name of the database mail profile. It’s a mandatory parameter @Profile_name:此参数的值是数据库邮件配置文件的名称。 这是必填参数
  2. @description: The value of this parameter is the description of the database mail profiles. This parameter is optional @description:此参数的值是数据库邮件配置文件的描述。 此参数是可选的

The procedure returns the profile ID of Database Mail. The sysadmin fixed server role must be granted to the user to execute this stored procedure.

该过程返回数据库邮件的配置文件ID。 必须将sysadmin固定服务器角色授予用户才能执行此存储过程。

msdb.dbo.sysmail_add_account_sp (msdb.dbo.sysmail_add_account_sp )

This stored procedure is used to add a database mail account. This account holds the SMTP account information. Below is the syntax of the stored procedure:

此存储过程用于添加数据库邮件帐户。 此帐户保存SMTP帐户信息。 下面是存储过程的语法:

Execute sysmail_add_account_sp   
@account_name =   'account name',  
@email_address =  'email address' ,  
    @display_name =  'display name' ,    
    @replyto_address =  'replyto address' ,    
    @description =  'description' ,    
@mailserver_name =  'server name',   
@mailserver_type =  'server type',   
@port =  port number,    
@username =  'user_name',    
@password =  'password',       
@enable_ssl =   enable SSL

The procedure accepts the following input parameters:

该过程接受以下输入参数:

  1. @account_name: The name of the account which you want to add. The datatype is sysname, and it’s a mandatory parameter @account_name:您要添加的帐户的名称。 数据类型为sysname,它是必填参数
  2. @email_address: This parameter is from the email address using which you want to send the email. For example, if you want to send an email address from @email_address:此参数来自您要用来发送电子邮件的电子邮件地址。 例如,如果要从DBA@dclocal.com, then the value of the DBA@
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值