問題描述
我正在使用 Mule 發送電子郵件.我需要為我發送的文本添加格式.郵件的內容是有效負載,其中包含我在 Java 方法中形成的字符串,并使用表達式轉換器發送到流.我需要為該字符串添加格式:粗體、下劃線、顏色......我該怎么做?
I'm sending emails using Mule. I need to add format to the text I send. The content of the mail is the payload which has a String in it that I form in a Java method and send to the flow with an Expression transformer. I need to add format to that String: bold, underline, colour.... How can I do it?
這是我的流程的摘錄:
<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="mail@mail.com" />
我試過這個,但它不起作用.
I've tried with this but it doesn't work.
<!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 : qqq@aaaa.com</h2><p>fin</p></body></html>
提前致謝.
推薦答案
我解決了.我錯過了將 smtp:connector 中的 content-type 和 smtp:outbpund-endbound 中的 mime-type 設置為 text/html 才能正常工作.這是正確的代碼:
I solved it. I was missing setting content-type in the smtp:connector and the mime-type in the smtp:outbpund-endbound as text/html for the to work. This is the correct code:
<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="mail@mail.com"" mimeType="text/html"/>
通過此配置,您可以像這樣在文本中使用 html
With this configuration you can use html in your text like this
<!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 : qqq@aaaa.com</h2><p>fin</p></body></html>
收到郵件時會顯示.
希望對其他人有所幫助.
Hope it'll help someone else.
這篇關于使用 Mule 發送格式化郵件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!