Mohammad Asif
Mohammad Asif

Reputation: 1

Format msdb.dbo.sp_send_dbmail

--SQL format

Declare @body As nvarchar(max)=N'<HTML>'
        +N'<p>Hi '+@userId+'</p>New amendment for act <b>'+@title+'</b> is added'
        +N'<p>This amendment include changes to the Section: <b>'+@sectionid+'</b> and Title: <b>'+@title+'.</b></p>'
        +N'<p>You are receiving this message because you have added change alert notification on Section: <b>'+@sectionid+'.</b></p>'
        +N'</HTML>'

on Receive email

<HTML><p>Hi zubairpayab</p>New amendment for act <b>Amendment of section 2C</b> is added<p>This amendment include changes to the Section: <b>2</b> and Title: <b>Amendment of section 2C.</b></p><p>You are receiving this message because you have added change alert notification on Section: <b>2.</b></p></HTML>

enter image description here

Can you help me to correct the format

Upvotes: -1

Views: 800

Answers (1)

Jayasurya Satheesh
Jayasurya Satheesh

Reputation: 8043

You need to specify the Body format as HTML while calling the sp_send_dbmail

EXEC dbo.sp_send_dbmail @profile_name = 'MyMailProfile',
                        @recipients = '[email protected]',
                        @copy_recipients = '[email protected]',
                        @body = 'HTML Body Content',
                        @body_format = 'HTML',
                        @subject = 'My Mail Subject'; 

Upvotes: 1

Related Questions