Home Database Mysql Tutorial SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

Jun 07, 2016 pm 03:17 PM
database ma server sql Configuration

SQL SERVER 2008 配置 Database Mail – 用 SQL 数据库发邮件 原文来自: http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/August 23, 2008 by pinaldave 今天这篇文章我们来讨论 database

SQL SERVER 2008配置Database Mail –SQL 数据库发邮件

原文来自:http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/  August 23, 2008 by pinaldave

今天这篇文章我们来讨论database mail,也就是用SQL server发邮件的问题。关于SQL Serverdatabase mailSQLMail的区别请参考SQL SERVER – Difference Between Database Mail and SQLMail. Database Mail代替了SQLMail的功能并有很大改进,所以非常建议放弃SQL Mail将其升级到Database Mail. 在此特别对软件开发工程师Monica致谢,感谢他为本文制作了题材广泛的测试和图片。

使用SQL Server发送电子邮件邮件需要三个基本配置步骤

1) 创建配置文件和帐户  2) 配置电子邮件  3) 发送电子邮件.

步骤1)创建配置文件和帐户

您需要创建一个配置文件和配置数据库邮件向导,用以访问配置数据库邮件管理节点中的数据库邮件节点及其上下文菜单中使用的帐户。可以使用此向导来管理帐户、 配置文件和数据库邮件的全局设置,如下所示:

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

Step 2)配置邮件:

在完成账户和配置文件创建之后,我们需要配置Database Mail.为了配置它,首先需要通过 sp_configure 存储过程,启用database mail XPs 参数,如下所示:<span>sp_CONFIGURE</span><span> </span><span>'show advanced'</span><span>, </span><span>1</span>
GO
<span>RECONFIGURE</span>
<span>GO</span>
<span>sp_CONFIGURE</span><span> </span><span>'Database Mail XPs'</span><span>, </span><span>1</span>
GO
<span>RECONFIGURE</span>
<span>GO</span>

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

Step 3) 发送邮件:

如上所有配置完成之后,我们就可以发邮件了,执行存储的过程的 <span>sp_send_dbmail</span>,并提供所需的参数,如下所示:

<span>USE </span><span>msdb</span>
GO
<span>EXEC </span><span>sp_send_dbmail</span><span> </span><span>@<span>profile_name</span></span><span>=</span><span>'<span>PinalProfile</span>'</span><span>,</span>
<span>@recipients</span><span>=</span><span>'test@Example.com'</span><span>,</span>
<span>@subject</span><span>=</span><span>'Test message'</span><span>,</span>
<span>@body</span><span>=</span><span>'This is the body of the test message.</span>
Congrates Database Mail Received By you <span>Successfully</span>.'

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

输入参数的所有验证都完毕后,邮件将在Service Broker中排序等待。关于这一点,更多信息请参见SQL SERVER – Introduction to Service Broker.

Database Mail将保留发出的电子邮件的副本,我们可以通过sysmail_allitemssysmail_sentitems,sysmail_unsentitemssysmail_faileditems来查询。邮件的发送状态将保存在<span>sysmail_mailitems</span>表中,成功发送时,该表中sent_status栏目将显示为1;发送失败时,sent_status栏目将显示为2,未发送时为3 
如下所示,日志文件可以在<span>sysmail_log</span> 表中查看

<span>SELECT </span><span>*</span>
<span>FROM </span><span>sysmail_mailitems</span>
GO
<span>SELECT </span><span>*</span>
<span>FROM </span><span>sysmail_log</span>
GO

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

发送状态可以在sysmail_sentitems表中验证.

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

发送之后就可以在收件箱查阅邮件了,如下图所示是作者收到的邮件

SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

The working principle and configuration method of GDM in Linux system The working principle and configuration method of GDM in Linux system Mar 01, 2024 pm 06:36 PM

Title: The working principle and configuration method of GDM in Linux systems In Linux operating systems, GDM (GNOMEDisplayManager) is a common display manager used to control graphical user interface (GUI) login and user session management. This article will introduce the working principle and configuration method of GDM, as well as provide specific code examples. 1. Working principle of GDM GDM is the display manager in the GNOME desktop environment. It is responsible for starting the X server and providing the login interface. The user enters

Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Jun 15, 2024 pm 09:49 PM

IntelArrowLakeisexpectedtobebasedonthesameprocessorarchitectureasLunarLake,meaningthatIntel'sbrandnewLionCoveperformancecoreswillbecombinedwiththeeconomicalSkymontefficiencycores.WhileLunarLakeisonlyavailableasava

Usage of division operation in Oracle SQL Usage of division operation in Oracle SQL Mar 10, 2024 pm 03:06 PM

"Usage of Division Operation in OracleSQL" In OracleSQL, division operation is one of the common mathematical operations. During data query and processing, division operations can help us calculate the ratio between fields or derive the logical relationship between specific values. This article will introduce the usage of division operation in OracleSQL and provide specific code examples. 1. Two ways of division operations in OracleSQL In OracleSQL, division operations can be performed in two different ways.

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

Detailed explanation of the Set tag function in MyBatis dynamic SQL tags Detailed explanation of the Set tag function in MyBatis dynamic SQL tags Feb 26, 2024 pm 07:48 PM

Interpretation of MyBatis dynamic SQL tags: Detailed explanation of Set tag usage MyBatis is an excellent persistence layer framework. It provides a wealth of dynamic SQL tags and can flexibly construct database operation statements. Among them, the Set tag is used to generate the SET clause in the UPDATE statement, which is very commonly used in update operations. This article will explain in detail the usage of the Set tag in MyBatis and demonstrate its functionality through specific code examples. What is Set tag Set tag is used in MyBati

Understand Linux Bashrc: functions, configuration and usage Understand Linux Bashrc: functions, configuration and usage Mar 20, 2024 pm 03:30 PM

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

How to install, uninstall, and reset Windows server backup How to install, uninstall, and reset Windows server backup Mar 06, 2024 am 10:37 AM

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

See all articles