-1

--SQL格式

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>'

在接收电子邮件

<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>

在此处输入图像描述

你能帮我纠正一下格式吗

4

1 回答 1

1

您需要在调用 sp_send_dbmail 时将正文格式指定为 HTML

EXEC dbo.sp_send_dbmail @profile_name = 'MyMailProfile',
                        @recipients = 'receiver@gmail.com',
                        @copy_recipients = 'cc@gmail.com',
                        @body = 'HTML Body Content',
                        @body_format = 'HTML',
                        @subject = 'My Mail Subject'; 
于 2021-09-16T05:43:34.733 回答