【问题标题】:Sending formatted mails with Mule使用 Mule 发送格式化邮件
【发布时间】:2014-11-28 12:04:43
【问题描述】:

我正在使用 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="mail@mail.com" />

我试过这个,但它不起作用。

<!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>

提前致谢。

【问题讨论】:

    标签: java email smtp format mule


    【解决方案1】:

    您也可以在 Mule 应用程序中使用 Velocity 模板。
    Velocity 是一个基于 Java 的模板引擎,可用于发送格式化的电子邮件。
    您还可以使用各种 HTML 标记来格式化您的内容
    参考 :- https://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html

    【讨论】:

      【解决方案2】:

      我解决了。 我错过了将 smtp:connector 中的 content-type 和 smtp:outbpund-endbound 中的 mime-type 设置为 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="mail@mail.com"" 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 : qqq@aaaa.com</h2><p>fin</p></body></html>
      

      收到邮件时会显示。

      希望对其他人有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-12-19
        • 2023-03-28
        • 2016-06-02
        • 2013-11-08
        • 2015-07-19
        • 2011-10-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多