SQL SERVER 2008 Configuration database mail– e-mail with SQL databases

Source: Internet
Author: User

SQL SERVER 2008 Configuration database mail– e-mail with SQL databases

https://blogs.msdn.microsoft.com/apgcdsd/2011/06/28/sql-server-2008database-mail-sql/

Originally from: http://blog.sqlauthority.com/2008/08/23/ Sql-server-2008-configure-database-mail-send-email-from-sql-database/august, by Pinaldave

In this article we are going to discuss Database Mail, which is the issue of sending mail with SQL Server. For the differences between Database Mail and SQLMail in SQL SERVER, refer to SQL Server–difference between Database Mail and SQLMail. Database Mail replaces the functionality of SQLMail and has been greatly improved, so it is highly recommended that SQL Mail be discarded to upgrade to Database Mail. In particular, Monica, a software development engineer, thanked him for making a wide range of tests and pictures for this article.

Three basic configuration steps required to send e-mail messages using SQL Server

1) Create profile and Account 2) Configure email 3) to send e-mail.

Steps 1) Create profiles and Accounts

You need to create a profile and configure Database Mail Wizard to access the accounts that are used in the Database Mail node and its context menu in the Metabase Mail Management node. You can use this wizard to manage the global settings for accounts, configuration files, and Database Mail as follows:

Step 2) Configure mail:

After completing the account and profile creation, we need to configure Database Mail. In order to configure it, you first need to enable the Database Mail XPs parameter through the sp_configure stored procedure as follows: sp_CONFIGURE ‘show advanced‘ , 1 GO RECONFIGURE GO sp_CONFIGURE ‘Database Mail XPs‘, 1 GO RECONFIGUREGO

<!--[endif]-->

Step 3) Send mail:

Once all the configuration is complete, we can send the message, execute the sp_send_dbmail of the stored procedure, and provide the required parameters as follows:

USE msdbGO EXEC sp_send_dbmail @profile_name=‘PinalProfile‘, @recipients=‘[email protected]‘, @subject=‘Test message‘, @body=‘This is the body of the test message.Congrates Database Mail Received By you Successfully.‘

<!--[endif]-->

After all validation of the input parameters is complete, the message is ordered to wait in Service Broker. For more information on this, see SQL Server–introduction to Service Broker.

Database Mail will keep a copy of the e-mail sent, and we can pass sysmail_allitems, Sysmail_sentitems, sysmail_unsentitems , sysmail_faileditems to inquire . The sending status of the message will be saved in the sysmail_mailitems table , and when sent successfully, the Sent_status column in the table will be displayed as 1; When sending fails, Sent_ The Status column will be displayed as 2, not sent as 3 as shown below, and the log file can be viewed in the sysmail_log table

SELECT *FROM  sysmail_mailitems GO SELECT * FROM  sysmail_logGO

<!--[endif]-->

The Send status can be verified in the Sysmail_sentitems table.

<!--[endif]-->

After you send it, you can check your email in your inbox, as shown in the message that the author received

<!--[endif]-->

Tags Database Mail

SQL SERVER 2008 configuration database mail– e-mail with SQL databases

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.