This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12901|Reply: 1

[Source] SQL Server Sending Mail Using Databases (sp_send_dbmail)

[Copy link]
Posted on 1/16/2018 7:04:01 PM | | |

In project development, many places need to send emails, such as placing orders, canceling orders, etc., which can be sent through program code (C#, Java, etc.), or through SQL statements using database triggers.

Sending mail using a database typically uses a stored procedure xp_sendmail or a sp_send_dbmail

(a)

xp_sendmail:It has gradually fallen out of use, its usage requirements 1: 32-bit Windows operating system is required (my computer is 64-bit, so I have not used it successfully on my computer) 2: It is necessary to specify the default email client 3: Permissions


(two)

sp_send_dbmail Stored procedures, the first thing you need to do is configure the work


The Database Mail Configuration Wizard provides an easy way to manage database mail configuration objects. The Database Mail Configuration Wizard will enable database mail as needed.

The Database Mail Configuration Wizard performs the following tasks:

Install database mail.

Manage database mail accounts and profiles.

Manage profile security.

View or change system parameters.

The Install Database Mail option will guide you through all the tasks you need to perform when you first install Database Mail. Other options help you with specific setup and maintenance tasks.

Start the database mail configuration wizard from Object Explorer. Connect to an instance of SQL Server. Expand Administration, right-click Database Mail, and select Configure Database Mail.

To use this wizard, you must be a member of the sysadmin fixed server role. You must be a member of the DatabaseMailUserRole database role in the msdb database to send database mail, which is configured in a specific way
It's much simpler to use:

Example:


Example:



Example:

Note: If Chinese garbled characters appear, please add N in front of Chinese, such as

(three)

Read the sending log, and the read of the sending event








Previous:vs What and why .pdb files are generated
Next:Send emails using database sp_send_dbmail
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com