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
|