我仍在试图弄清楚,为什么我不能在自定义电子邮件的正文中应用 HTML 格式。我确定我错过了什么,或者我需要一双新的眼睛!
这是添加到 <head>
的信息网页的
<head runat="server">
<link href="~/MyStyle.css" rel="stylesheet" type="text/css" />
</head>
Mystyle.css
包含以下内容
span.orange
{
color: #FF6D06;
font-family: tahoma;
font-size: 10pt;
}
这里是 body 部分......
Dim HtmlString as string = "<span class='orange'>This one should be painted</span>"
使用 Net.Mail 发送
Dim objMail As New Mail.MailMessage (blah, blah blah)
objMail.IsBodyHtml = True
更新:首先感谢您的评论。电子邮件本身不会以任何方式被样式表引用。那么除了将样式表附加到电子邮件之外,我还有哪些选择?
最佳答案
完成此操作后,我通常会将 CSS 嵌入到电子邮件正文中:
<html>
<head>
<style type="text/css">
span.orange
{
color: #FF6D06;
...
}
</style>
</head>
...
避免在 HTML 电子邮件中引用外部实体(如样式表、图像等)。这些引用可能不可用,具体取决于用户的邮件代理设置。此外,了解邮件代理中的 HTML 支持。它可能没有你想象的那么丰富。 Here's some information on Outlook ,例如。
https://stackoverflow.com/questions/1934130/