Question : XP SMTP Mail

The attached code takes a tamplate HTML file, converts it to a string variable , Substitutes some values with data from a tempfile and the this strin field should be the message value to send.

All the emails are sent, but the body of the email is blank?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
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

Answer : XP SMTP Mail

Is it really blank? An error in the HMTL code may prevent it from displaying correctly...
In your e-mail software, can you view the source code of the e-mail? Check if something is there. If your HTML code shows up then there is a problem with the HTML itself. If it doesn't the problem is probably in the script.
Random Solutions  
 
programming4us programming4us