Step - 1 --------- use master go sp_configure 'show advanced options',1 go reconfigure with override go sp_configure 'Database Mail XPs',1 --go --sp_configure 'SQL Mail XPs',0 go reconfigure go Step - 2 -------- EXECUTE msdb.dbo.sysmail_add_account_sp @account_name = 'MyMailAccount', @description = 'Mail account for Database Mail', @email_address = 'makclaire@optonline.net', @display_name = 'MyAccount', @username='makclaire@optonline.net', @password='abc123', @mailserver_name = 'mail.optonline.net' Step-3 ------- EXECUTE msdb.dbo.sysmail_add_profile_sp @profile_name = 'MyMailProfile', @description = 'Profile used for database mail' Step -4 --------- EXECUTE msdb.dbo.sysmail_add_profileaccount_sp @profile_name = 'MyMailProfile', @account_name = 'MyMailAccount', @sequence_number = 1 Step-5 -------- EXECUTE msdb.dbo.sysmail_add_principalprofile_sp @profile_name = 'MyMailProfile', @principal_name = 'public', @is_default = 1 ; Step-6 ------- declare @body1 varchar(100) set @body1 = 'Server' +@@servername+ 'My First Database Emai' EXEC msdb.dbo.sp_send_dbmail @recipients='myemail@yahoo.com' @subject = My Mail Test, @body = @body1, @body_format = 'HTML' -------------
select * from msdb.dbo.sysmail_event_log
EXEC msdb.dbo.sp_send_dbmail @recipients='User@dmain.com', @subject = 'Subject Line', @body = 'Hello', @body_format='HTML', @profile_name = 'Profile1', @file_attachments = 'C:\attachment.txt'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)