This stored procedure is in placed the msdb database.
Syntax and parameters:
sp_send_dbmail @profile_name , @recipients , @copy_recipients, @blind_copy_recipients , @from_address, @reply_to, @subject, @body, @body_format, @importance, @file_attachments
sp_send_dbmail @profile_name , @recipients , @copy_recipients, @blind_copy_recipients , @from_address, @reply_to, @subject, @body, @body_format, @importance, @file_attachments
Example send email with file attached:
declare @_recipients nvarchar(max)=''
declare @_ord_id nvarchar(255)declare @_subject nvarchar(max)
declare @_body nvarchar(max)
set @_subject = 'Order with id=11 was delivered.';
set @_recipients = 'to@domain.com'
exec msdb.dbo.sp_send_dbmail @profile_name = 'smtp profile name',
@recipients = @_recipients,Where to find the definition?
USE msdb;
GO SELECT
definition Database Mail Configuration Wizard
To start the Database Mail Configuration Wizard, in Object Explorer, expand Management, right-click Database Mail, and then click Configure Database Mail.