我正在使用 Mule 发送电子邮件。我需要为发送的文本添加格式。
邮件的内容是有效负载,其中包含我在 Java 方法中形成的字符串,并使用表达式转换器发送到流程。
我需要向该字符串添加格式:粗体、下划线、颜色......
我该怎么做?
这是我的流程的摘录:
<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>
提前致谢。
我解决了。
我缺少设置smtp:connector 中的内容类型和smtp 中的 mime 类型: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>
并会在收到电子邮件时显示。
希望它能帮助别人。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)