2012-03-26 15 views
1

我有一个用于从SQL Server发送电子邮件的存储过程。在sp_send_dbmail(SQL Server)中不应用于电子邮件的CSS样式

电子邮件需要以HTML格式发送。

但是,当收件人显示电子邮件时,它没有应用于电子邮件的CSS样式。它只是简单地显示它的文字。

下面找到我的代码:

EXEC msdb.dbo.sp_send_dbmail 
@profile_name = 'mail-profile-name' , 
@recipients = '[email protected]' , 
@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'; 

谢谢。

+1

如果你看一下电子邮件的“原始来源”,这是什么节目?具体来说,我试图确定这是SQL Server的问题还是电子邮件客户端的问题。 – 2012-03-26 17:21:30

回答

4

我发现内部或嵌入式样式不能应用于电子邮件的正文。

取而代之,我已经使用了现在正在工作的内联样式。该电子邮件现在正在显示,因为它应该。

查找下面的代码:

EXEC msdb.dbo.sp_send_dbmail 
@profile_name = 'mail-profile-name' , 
@recipients = '[email protected]' , 
@body = '<html> 
<H1 style="color: #0000FF"><span style="font-weight: normal;">Sales</span> Reports</H1><body> 
<table border = 2><tr><th style="background-color: #00FF00">Product ID </th> 
<th style="background-color: #FF0000">SaleAmount</th></tr></table></body> </html>' , 
@subject = 'AUTOMATED ALERT' , 
@body_format = 'HTML'; 
相关问题