我有一个用于从 SQL Server 发送电子邮件的存储过程。
电子邮件需要以 HTML 格式发送。
但是当显示在收件人的电子邮件中时,它没有应用于电子邮件的 CSS 样式。它只是将其显示为简单的文本。
在下面找到我的代码:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'mail-profile-name' ,
@recipients = 'myemail@gmail.com' ,
@body = '<html>
<head>
<style type="text/css">
.style1
{
font-weight: normal;
}
</style>
</head>
<H1><span class="style1">Sales</span> Reports</H1><body bgcolor=yellow>
<table border = 2><tr><th>Product ID </th><th>SaleAmount</th></tr></table></body> </html>' ,
@subject = 'AUTOMATED ALERT' ,
@body_format = 'HTML';
Run Code Online (Sandbox Code Playgroud)
谢谢你。