EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'YOUR MAIL PROFILE',
@recipients = '[email protected]',
@body = 'Copy and Purge BAKs success !!',
@subject = 'Copy and Purge BAKs success',
-- to send file attachments
@file_attachments = 'D:\logs\log.TXT',
-- Change below if you want to include query results from a table in the email.
-- Note that below is not in HTML
@query = 'select column1, column2 from table1';
第 3 步 - 失败电子邮件
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'YOUR MAIL PROFILE',
@recipients = '[email protected]',
@body = 'Copy and Purge BAKs failed !!',
@subject = 'Copy and Purge BAKs failed',
-- to send file attachments
@file_attachments = 'D:\logs\log.TXT',
-- Change below if you want to include query results from a table in the email.
-- Note that below is not in HTML
@query = 'select column1, column2 from table1';
你必须使用 tsql 来做到这一点。
在主要工作步骤之后的工作步骤中,再添加 2 个工作步骤:
第二步——成功邮件
第 3 步 - 失败电子邮件
然后使用 tsql
sp_send_dbmail
注意:如果您希望发送 HTML 电子邮件,我有一个脚本可以帮助您。