[英]seam mail and CSS (How does it work?)
您如何以良好的方式處理接縫郵件和樣式? 我已經在Google上搜索了好幾個小時,但是找不到一種設置電子郵件樣式的好方法。 數據表根本沒有樣式,甚至沒有“標准”邊框等。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>
您是否嘗試過<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>
無法使它正常工作。 解決方案是將其扔掉並使用Java郵件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.