我正在尝试用HTML正文发送电子邮件。
我在这个网站和其他地方找到了很多例子,很好地解释了如何使用
LinkedResource
类型的HTML标签的类
IMG
.
在我的情况下,我有以下代码:
<table id="page" style="border: 2px solid #ff0000; ">
<tr>
[...]
</tr>
</table>
和以下样式表:
#page {
width: 100%;
height: 100%;
top: 0;
right: 0;
background: url(https://www.example.com/img/bg.jpg) no-repeat center center;
position: fixed;
z-index: -1;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
下面是代码:
MailMessage mail = new MailMessage();
AlternateView plainView = AlternateView.CreateAlternateViewFromString( plainTextMessage, Encoding.UTF8, "text/plain" );
mail.AlternateViews.Add( plainView );
AlternateView htmlView = AlternateView.CreateAlternateViewFromString( htmlTextMessage, Encoding.UTF8, "text/html" );
mail.AlternateViews.Add( htmlView );
mail.Body = htmlTextMessage;
mail.IsBodyHtml = true;
mail.To.Add( new MailAddress( customer.Email, customer.FullName ) );
mail.From = new MailAddress( "noreply@example.com", "My Web site" );
SmtpClient client = new SmtpClient();
client.Send( mail );
如何使用LinkedResource类嵌入背景图像?