对电子邮件的CSS [英] CSS on Email

查看:174
本文介绍了对电子邮件的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人找到了编程产生的电子邮件embeding CSS的好方法。我发现,最好的办法就是把款式code到一个资源文件并调用到code。

这是emample是

 暗淡objBuilder
objBuilder =新的StringBuilderobjBuilder.Append(Resources.SystemEmail.CSSStyle)
objBuilder.Append(我的样式化通过电子邮件将)昏暗_Body作为字符串= objBuilder.ToString()

这将建立电子邮件的正文

有没有什么办法让一个电子邮件模板文件或一个更好的方式来样式表调入之一。

在我的.resx文件的code将

 <风格类型=文/ CSS>
<! -
身体
{    FONT-FAMILY:宋体,宋体,Arial字体;
    字体大小:10PT;
    填充:3PX 0像素0像素0像素;
    保证金:0像素0像素0像素0像素;}
- >
< / STYLE>

和调用到字符串这将调用此内联

和下面的答案发送消息我会用这种

 昏暗的客户端作为新SmtpClient(localhost的)
昏暗toAddr作为新的MailAddress(MailRecipients)
昏暗fromAddr作为新的MailAddress(的MailFrom)
昏暗的消息作为MAILMESSAGE新(FROMADDRESS,的toAddress)
message.Subject =课题
message.Body = _Body
message.IsBodyHtml = TRUE
message.BodyEncoding = System.Text.Encoding.UTF8client.Send(消息)


解决方案

我们已经成功的唯一方法是,以包括CSS内联。文档标题样式CSS列入不一致或可靠的。

此外,请确保您的邮件信头被设置为:
内容类型:text / html的;字符集= ISO-8859-1

修改
UTF-8也是一个不错的选择。这句话的关键点是内容类型被设置为text / html

Has anyone found a good way of embeding CSS in a programatically produced email. The best way I have found is to put the style code into a resource file and call it into the code.

An emample would be

Dim objBuilder
objBuilder = New StringBuilder

objBuilder.Append(Resources.SystemEmail.CSSStyle)
objBuilder.Append("My Styled Email")

Dim _Body As String = objBuilder.ToString()

This would build the body of the email

Is there any way to make a template file for an email or a better way to call a style sheet into one.

The code in my .resx file would be

<STYLE TYPE="text/css">
<!--
body
{

    font-family: Tahoma, Verdana, Arial;
    font-size: 10pt;
    padding: 3px 0px 0px 0px;
    margin: 0px 0px 0px 0px;

}
-->
</STYLE>

And calling this into the string would call this inline

And with the answers below to send the message I would use this

Dim client As New SmtpClient("localhost")
Dim toAddr As New MailAddress(MailRecipients)
Dim fromAddr As New MailAddress(MailFrom)
Dim message As New MailMessage(fromAddress, toAddress)


message.Subject = "The Subject"
message.Body =  _Body 
message.IsBodyHtml = True
message.BodyEncoding = System.Text.Encoding.UTF8

client.Send(message)

解决方案

The only way we've been successful is to include the CSS inline. Document Header style CSS inclusion isn't consistent or reliable.

Also, make sure your email headers are set to: Content-type: text/html; charset=ISO-8859-1

EDIT UTF-8 is also a good option. The KEY point of that statement is the Content-type being set to text/html

这篇关于对电子邮件的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆