OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @email,@meeting,@url,@begindate,@description,@begintime,@endtime
WHILE @@FETCH_STATUS = 0
BEGIN
--
-- Open template file
--
CREATE TABLE #tempXML(PK INT NOT NULL IDENTITY(1,1), ThisLine VARCHAR(255))
SET @FileContents = ''
INSERT INTO #tempXML EXEC master.dbo.xp_cmdshell @ExecCmd
SELECT @y = count(*) from #tempXML
SET @x = 0
WHILE @x <> @y
BEGIN
SET @x = @x + 1
SELECT @FileContents = @FileContents + ThisLine from #tempXML WHERE PK
= @x
END
-- select @filecontents
--
-- Perform substitutions
--
select @filecontents = replace(@filecontents,'Title',@description)
select @filecontents = replace(@filecontents,'Prog_Date',@begindate)
select @filecontents = replace(@filecontents,'Start_Time',@begintime)
select @filecontents = replace(@filecontents,'End_Time',@endtime)
set @embedded = '' + @Description + ''
select @filecontents = replace (@filecontents,'embedded_link',@embedded)
declare @rc int
exec @rc = master.dbo.xp_smtp_sendmail
@FROM = N'[email protected]',
@TO = N'[email protected]',
@subject = N'Hello HTML SQL Server SMTP Mail',
@message = @filecontents,
@type = N'text/html',
@server = N'mclemail01'
select RC = @rc
drop table #tempXML
FETCH NEXT FROM db_cursor INTO @email,@meeting,@url,@begindate,@description,@begintime,@endtime
END
|