Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2007
    Posts
    2

    Unanswered: sending html formatted email within a stored procedure

    hi there,

    the subject line says it all. is there a way to send nicely formatted html email from within a stored procedure that returns a dataset?

    thanks!

    chris

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    SQL Server 2005:
    Code:
    DECLARE @MessageSubject	varchar(255)
    DECLARE @MessageBody	nvarchar(Max) 
    DECLARE @EmailRecipient char(255)
    
    SET @EmailRecipient	= 'your@email.com'
    SET @MessageSubject 	= 'Nicely formatted email sent from SQL Server'
    SET @MessageBody	=
    			N'Insert your HTML here' +
    			N'<br>New line...' +
                            N'<br><b>etc</b>, hopefully you get the idea'
    
    EXEC 	msdb..sp_send_dbmail
    	@recipients 	= @EmailRecipient	,
    	@subject	= @MessageSubject	,
    	@body 		= @MessageBody		,
    	@body_format 	= 'HTML'		;
    George
    Home | Blog

  3. #3
    Join Date
    Oct 2007
    Posts
    2

    great

    thank you so so so so much!!!

Posting Permissions

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