|
CREATE DATABASE NewsletterEmailsDb
GO
USE NewsletterEmailsDb
GO
CREATE TABLE NewsletterEmails
(
Id int PRIMARY KEY IDENTITY(1,1),
Email varchar(50)
)
GO
CREATE PROCEDURE [SendNewsletterMails]
(
@Email varchar(max),
@Body text,
@Subject varchar(255)
)
as
EXEC msdb.dbo.sp_send_dbmail
@blind_copy_recipients=@Email,
@body= @Body,
@subject = @Subject,
@body_format = 'HTML',
@profile_name = 'MyDBMail'
GO
-- configuring sql smpt email sender
USE msdb
GO
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'MyAccount', @email_address = 'sender@provider.com', @display_name = 'sender name', @mailserver_name = 'localhost'
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'MyDBMail'
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'MyDBMail', @account_name = 'MyAccount', @sequence_number = 1
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.