|
CREATE TABLE [dbo].[NewsletterEmails]
(
[Id] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
NAME [varchar](50) NULL,
[Email] [varchar](50) NULL
)
GO
CREATE TABLE ProcessLog
(
Id int PRIMARY KEY IDENTITY(1,1),
StartDate datetime,
EndDate datetime,
EmailsSent int,
SendFailed int,
LogFile varchar(max)
)
GO
CREATE PROCEDURE [dbo].[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.