Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002

    Unanswered: xp_smtp_sendmail Not Sending HTML File Right

    Hello All.

    I sent a HTML file as text message using xp_smtp_sendmail from my SQL server but the test email that I received doesn't look like the HTML file I have originally. Below are my codes:-

    exec @rc = master.dbo.xp_smtp_sendmail
    @FROM = N'',
    @FROM_NAME = N'Mr XXX',
    @TO = N'',
    @CC = N'',
    @priority = N'HIGH',
    @subject = N'Weekly Sales To Thirds',
    @type = N'text/html',
    @messagefile = N'D:\WST\WeeklySalesToThirds.htm',
    @server = N'999.99.999.99',
    @attachments = N'D:\WST\4weeks\WST.xls'
    select RC = @rc

    The problem I have is the email doesn't display the HTML correctly. Spaces appeared and some of wording have wrapped.

    I have attached partial screen shots of my original HTML file and email.

    Please help if you have similar problem and solution. Thank you.

    Best regards
    Teck Boon
    Attached Thumbnails Attached Thumbnails Orginal_HTML_File.bmp   In_Email.bmp  

  2. #2
    Join Date
    Jan 2007
    Provided Answers: 12
    If it helps; this is the code I use to send HTML e-mails in SQL Server 2005
    DECLARE @MessageSubject	varchar(255)
    DECLARE @MessageBody	nvarchar(MAX) 
    DECLARE @EmailRecipient char(255)
    SET @EmailRecipient	= ''
    SET @MessageSubject 	= 'Message subject :)'
    SET @MessageBody	=
    			N'Some text' +
    			N'<br />' +
    			N'More text' +
    			N'<br />' +
    			N'Last bit of text'
    EXEC 	msdb..sp_send_dbmail
    	@recipients 	= @EmailRecipient	,
    	@subject	= @MessageSubject	,
    	@body 		= @MessageBody		,
    	@body_format 	= 'HTML'		;
    Home | Blog

  3. #3
    Join Date
    Jun 2002
    Hi georgev

    Thank you for the reply but I need to attach the HTML as a file because it is generated from another process (from excel). It is not just standard fixed text but text with a daily report where numbers change.

    I have previously did the same and it works. Maybe the width of the HTML is small as compared to the latest.

    I am also attaching it as a file but the business has requested it to show the summary page in the body of the email and the details as an attached file.

    Best regards
    Teck Boon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts