使用Velocity生成基于HTML的电子邮件 [英] Use Velocity to generate HTML based email
问题描述
我尝试本教程 http://www.java2s.com/Code/ Java / Velocity / UseVelocitytogenerateHTMLbasedemail.htm
但是,当我添加css时,它看起来好像没有执行。
I try this tutorials http://www.java2s.com/Code/Java/Velocity/UseVelocitytogenerateHTMLbasedemail.htm but, when i add css, it look like not executed.
<HTML>
<HEAD>
<TITLE>Pet Store Sale!</TITLE>
<style type="text/css">
body {
margin: 0 0 0 0;
padding: 0 0 0 0;
text-align: center;
background-color: #FFF;
border-top: 3px solid #CCC;
}
#container {
position: relative;
width: 860px;
height: 1600px;
margin: 84 auto 0 auto;
padding: 0 0 0 0;
background-color: #FFF;
}
p {
font-family: times, Times New Roman, times-roman, georgia, serif;
color: #444;
margin: 0 0 0 0;
padding: 0 0 0 0;
text-align: center;
}
.woodtwo {
font-size: 22px;
line-height: 46px;
letter-spacing: -1px;
}
.eyebrow {
font-size: 19px;
line-height: 29px;
}
.caps {
font-size: 14px;
line-height: 20px;
text-transform: uppercase;
}
.copyone {
font-size: 16px;
line-height: 20px;
}
#line {
border-bottom: 1px solid #CCC;
width: 748px;
margin: 10 0 20 56;
}
#break {
height: 30px;
}
a:link { color: #B95E27; text-decoration: none; }
a:visited { color: #B95E27; text-decoration: none; }
a:active { color: #1A69A1; text-decoration: none; }
a:hover { color: #888; text-decoration: none;}
.grey { color: #888; }
.smallcaps { font-size: 88%; }
</style>
</HEAD>
<BODY>
<div id="container">
<p class="caps"><a href="">From Pet Store Sale</a></p>
<div id="line"></div>
<p class="eyebrow">
<span class="grey">*</span>T<span class="smallcaps">HANK YOU FOR JOINING </span>P<span class="smallcaps">ET</span> S<span class="smallcaps">TORE</span> S<span class="smallcaps">ALE</span> A<span class="smallcaps">PPLICATION</span><span class="grey">*</span>
</p>
<p class="copyone">
<i>You received this email because your registration process in Pet Store Sale is successful.<br/>
To Confirm your registration, please visit this link <a href ="$link">Confirmation Link</a>.<br/>
Your username : $username<br/>
Password : $password<br/>
If you have any questions about Application, please send an email to <a href="mailto:admin@store.com">admin@store.com</a></i>
<br><br><b>THANK YOU</b>
</p>
<div id="break"></div>
<p class="woodtwo">
<a href="">GETTING STARTED</a>
<div id="line"></div>
<div id="line"></div>
</div>
</BODY>
</HTML>
我也试过
<link rel="stylesheet" href="./style/css/emailFormat.css" type="text/css" media="screen" />
但它也不起作用。
如何以正确的方式将css添加到此页面。谢谢
but it not work too. how the right way to add css on to this page. Thank you
推荐答案
电子邮件客户端会忽略CSS类。如果您使用Outlook Express等独立客户端, div
s也将无法识别(不依赖于 float:left
)。
CSS classes are ignored by email clients. If you are using standalone clients like Outlook Express, div
s will also not be recognized (dont depend on float:left
).
我建议你改变你的HTML页面 -
I suggest you to change your HTML page like -
- Drop
< body> ...< / body>
- 之外的所有内容
使用 < table>
而不是< div>
- 不要使用
< style>
用于定义样式类的标记,或用于加载样式的.css文件。而是在< td>
/ <$ c $内使用内联css,如style =....
c>< table> 容器。
- Drop everything outside the
<body>...</body>
- Use
<table>
instead of<div>
- Dont use
<style>
tags to define style-classes, or .css file to load styles. Instead use inline css likestyle="...."
inside the<td>
/<table>
containers.
希望这可以帮助您完成电子邮件模板设计。
Hope this helps you in email template designing.
这篇关于使用Velocity生成基于HTML的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!