1, open the database, find the management to find the Database Mail, right-click Select Configuration
2, Direct next
3.
4 fill in the basic configuration information, the mailbox password should not be written wrong. Otherwise will not send out the mail, also won't error!
Click Next directly. Then finish.
At this point, the configuration is basically successful. , and then to test whether the configuration was successful. Can be executed using the following script.
Then there are several ways to receive the mailbox, (1 Normal text Right-click, with Attachments right-click, the query results as an attachment)
exec dbo.sp_send_dbmail @profile_name = ' toemail ',--this is the name you wrote above,
@recipients = ' [email protected] ',--This is the email address you want to receive
@subject = ' This is a test message ',--This is the title
@body = ' content '-this is a simple textual content
----------------------------a gorgeous delimiter----------------------------------------------------------
---this is about the query results as an attachment sent to the specified mailbox
EXEC Dbo.sp_send_dbmail
@profile_name = ' Toemail ',
@recipients = ' [email protected] ',
@subject = ' query result ',
@body = ' Query results in attachment ',
@query = ' SELECT top ' from Test.dbo.Table1 ',
@attach_query_result_as_file = 1,
@query_attachment_filename = ' tablle1.txt '---attachment name customization.
GO
----------------------------a gorgeous delimiter----------------------------------------------------------
Next we look at the results.
Over
SQL Server enable mailbox service