How to send emails through SQL stored procedures

Source: Internet
Author: User
Tags sql server query mssqlserver mail account microsoft outlook
How do I configure SQLServer to use the Internet mail server to send emails? See the following:

How do I configure SQL Server to use the Internet mail Server to send mails? See the following:

How does SQL Server configure email sending?
Generally, we all know that SQL Server and Microsoft Exchange Server are well integrated. The configuration in this regard is described in detail in SQL Server's online help and will not be repeated here. However, we are more concerned about how to configure SQL Server to use the Internet mail Server to send emails without the Exchange Server?


I used to find relevant information on the Internet, and found that some of the only documents were taken with a stroke, while some described the operation steps, you can perform the operations step by step, and the results will always fail. For this reason, I tried to find a simple and effective method, and did not dare to enjoy it alone. The following is a detailed configuration step. If you encounter any problems during the operation, please leave a message.


Test environment:


1 Windows 2000 Server
2 SQL Server 2000 + SP3
3 Microsoft OutLook (Office 2000)


Prepare an Internet mail account:


Test email account: test@jb51.net
Smtp server smtp.163.com
Pop3 server pop.163.com


Step 1: Change email Configuration


1. Open Microsoft OutLook, click "options" in the "Tools" menu, and then click the "mail service" tab.
2. Click "reconfigure email support ".
3. Select "for enterprise or workgroup ".
4. Restart Microsoft OutLook


Step 2: Add a configuration file


1. Click "service" in the "Tools" menu, and then click "add.
2. Select "Internet email" and click "OK ".
3. The following procedure is to set up an email account. For details, refer to the Microsoft Outlook help file.
4. Use the configured email account to send and receive emails and confirm that the configuration is successful.


Step 3: configure the MSSQLSERVER Service to use the mail configuration file


1. Restart the MSSQLSERVER service. (required. Otherwise, the MSSQLSERVER service cannot detect the configuration file added in the previous step)
2. Choose Enterprise Manager> Expand Server> Support Services> right-click "email"> click the drop-down list and you will find
"Microsoft Outlook Internet Settings" option, click "test ". If the dialog box Indicating success is displayed, congratulations, it's done.


Step 4: enjoy the fruits of your work


1. Open the SQL Server Query Analyzer


2. Enter the following SQL statement and run
Exec master.. xp_sendmail 'test @ jb51.net', 'Hello, World! '


3. Go to your mailbox to receive emails!


Note: The above configuration process requires you to log on to Windows 2000 Server with a Windows account used by the MSSQLSERVER service, that is, the account you use to log on to the computer must be the same as the Windows account used by the MSSQLSERVER service.

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.