如何以良好的方式处理缝合邮件和样式?我用谷歌搜索了几个小时,但我找不到一个很好的方式来设置我的电子邮件。数据表完全没有风格,甚至没有“标准”边框等.Seam版本是2.2.2。
基本上发送带风格的邮件的好习惯是什么?非常感谢。
以下小平面:
<m:message xmlns="http://www.w3.org/1999/xhtml"
xmlns:m="http://jboss.com/products/seam/mail"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:s="http://jboss.com/products/seam/taglib">
<m:from name="#{message.mailFrom}" address="k.kilden@logica.com" />
<m:to name="mailFromName" address="k.kilden@logica.com" />
<m:subject>
<h:outputText value="#{message.mailTopic} Orderid: #{order.id}" />
</m:subject>
<m:body>
<f:facet name="alternative">Sorry, your email reader can't show our fancy email</f:facet>
<html>
<head>
<a4j:loadBundle var="message" basename="messagesGenericPurchase" />
<link href="#{facesContext.externalContext.requestContextPath}/stylesheet/mail.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>#{message.mailHeadLine} #{order.form.name}</h2>
<hr style="border:1px solid red;"></hr>
<h:outputText value="#{message.mailOrderHead}"
style="font-weight:bold; line-height:20px;" />
<rich:dataTable var="hField" value="#{order.headFields}">
<rich:column style="width: 100px;">
<h:outputText value="#{hField.field.label}" />
</rich:column>
<rich:column style="width: 100px border:2px;">
<h:outputText value="#{hField.value}" style="border:2px;"/>
</rich:column>
</rich:dataTable>
</body>
</html>
</m:body>
</m:message
在outlook中生成输出:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link href="http://dl.dropbox.com/u/860312/genericPurchase.css" rel="stylesheet" type="text/css">
</head>
<body>
<h2>Ny beställning: Arbetskläder3</h2>
<hr style="border:1px solid red;"><span style="font-weight:bold; line-height:20px;">Orderhuvud</span><table class="rich-table " id="j_id11" border="0" cellpadding="0" cellspacing="0"><colgroup span="2"></colgroup><tbody id="j_id11:tb"><tr class="rich-table-row rich-table-firstrow "><td class="rich-table-cell " id="j_id11:0:j_id12" style="width: 100px;">test</td><td class="rich-table-cell " id="j_id11:0:j_id14" style="width: 100px border:2px;"><span style="border:2px;">asd</span></td></tr><tr class="rich-table-row "><td class="rich-table-cell " id="j_id11:1:j_id12" style="width: 100px;">test</td><td class="rich-table-cell " id="j_id11:1:j_id14" style="width: 100px border:2px;"><span style="border:2px;">asd</span></td></tr><tr class="rich-table-row "><td class="rich-table-cell " id="j_id11:2:j_id12" style="width: 100px;">test</td><td class="rich-table-cell " id="j_id11:2:j_id14" style="width: 100px border:2px;"><span style="border:2px;">asd</span></td></tr></tbody></table>
</body>
</html>
答案 0 :(得分:1)
你试过<m:body type="html"> </m:body>
吗?
这允许您直接在文本中添加标签。
不知道你是否找到了解决方案,但这对我有用。我将CSS样式直接添加到邮件模板中:
<m:body type="html">
<head>
<f:verbatim escape="true"> <style>
.table {
text-align: left;
font-size: 11px;
width:100%;
font-family:Arial,Verdana,sans-serif;
}
.body {
font-size: 11px;
margin: 0px;
color:black;
font-family:Arial,Verdana,sans-serif;
}</style> </f:verbatim>
</head>
然后在我的消息文本中,我使用我创建的样式类:
"<p class='body'>here's some css styled text"</p>
答案 1 :(得分:0)
无法让这个工作。解决方案是抛弃它并使用java邮件