2014-10-03 154 views
1

我使用Mule发送电子邮件。我需要为我发送的文本添加格式。 邮件的内容是有一个字符串的有效载荷,我在Java方法中形成并通过表达式转换器发送到流。 我需要为该字符串添加格式:粗体,下划线,颜色.... 我该怎么做?用Mule发送格式化的邮件

这是我流的摘录:

<expression-transformer expression="#[com.generateText4Email(payload)]" doc:name="mailText"/> 
<smtp:outbound-endpoint host="${smtp.host}" 
     responseTimeout="10000" doc:name="SMTP" connector-ref="smtpConnector" 
     from="${smtp.from}" port="${smtp.port}" subject="Invoice" 
     to="[email protected]" /> 

我这个尝试,但它不工作。

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"><head><title>Email</title></head><body style="font-family:'Century Gothic'"><h1 style="text-align:center;"> company </h1><h2 style="font-size:14px;">Name : name <br />Company : arch <br />Email : [email protected]</h2><p>fin</p></body></html> 

在此先感谢。

回答

4

我解决了它。 我缺少设置内容类型的smtp:连接器MIME类型的smtp:outbpund-endbound作为text/html的工作。 这是正确的代码:

<smtp:connector name="smtpConnector" 
    validateConnections="true" doc:name="SMTP" contentType="text/html"/> 
<smtp:outbound-endpoint host="${smtp.host}" 
    responseTimeout="10000" doc:name="SMTP" connector-ref="smtpConnector" 
    from="${smtp.from}" port="${smtp.port}" subject="Invoice" 
    to="[email protected]"" mimeType="text/html"/> 

有了这个配置,你可以使用HTML文本中的这样

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"><head><title>Email</title></head><body style="font-family:'Century Gothic'"><h1 style="text-align:center;"> company </h1><h2 style="font-size:14px;">Name : name <br />Company : arch <br />Email : [email protected]</h2><p>fin</p></body></html> 

和接收电子邮件时会显示。

希望它能帮助别人。

相关问题