WSO2 EI6.6:发送带有附件和HTML身体的电子邮件

发布于 2025-01-29 10:53:36 字数 2776 浏览 4 评论 0原文

我正在尝试发送带有WSO2EI6.6附件的电子邮件。当我尝试使用一些文本作为电子邮件主体时,该代码正常工作。当我尝试发送HTML内容时,它无法正常工作。 HTML代码适用于表,我希望在电子邮件正文中看到表格,但HTML代码在电子邮件正文中显示为文本。

序列

    <?xml version="1.0" encoding="UTF-8"?>
<sequence name="EmailSend_SEQ" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <payloadFactory media-type="xml">
        <format>
            <ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:text>
        </format>
        <args>
            <arg evaluator="xml" expression="get-property('emailBodyWithRec')"/>
        </args>
    </payloadFactory>
    <property value="Sample Email" name="Subject" scope="transport" type="STRING"/>
    <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
    <property name="messageType" scope="axis2" type="STRING" value="text/html"/>
    <property name="ContentType" scope="default" type="STRING" value="text/html"/>
    <property name="transport.mail.Format" scope="axis2" type="STRING" value="Attachment"/>
    <property expression="get-property('sAttachmentFileName')" name="AttachmentFile" scope="axis2" type="STRING"/>
    <header expression="fn:concat('mailto:', get-property('primaryEmail'))" name="To" scope="default"/>
    <call/>
    <property name="OUT_ONLY" scope="default" type="STRING" value="false"/>
    <payloadFactory media-type="xml">
        <format>
            <EmailNotificationResponse>
                <Status xmlns="">SUCCESS</Status>
            </EmailNotificationResponse>
        </format>
        <args/>
    </payloadFactory>
</sequence>

html含量:

<html xmlns="http://ws.apache.org/ns/synapse" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <head>
      <meta content="width=device-width, initial-scale=1.0" name="viewport"/><style>table, td, th {   border: 1px solid black;}table {  text-align: center;    border-collapse: collapse;   font-weight:bold}td { width: 140px;}</style></head>
   <body>
      <table>
         <tr>
            <th>Transactions Processed</th>
            <td>1111110</td>
         </tr>
         <tr>
            <th>Success</th>
            <td>0</td>
         </tr>
         <tr>
            <th>Expired</th>
            <td>0</td>
         </tr>
         <tr>
            <th>Failed</th>
            <td>0</td>
         </tr>
      </table>
   </body>
</html>

I am trying to send an email with attachment from WSO2EI6.6. The code is working as expected when I tried with some text as email body. When I tried to send HTML content, it is not working as expected. The HTML code is for a table and I am expecting to see the table in email body but the HTML code is displayed in email body as text.

Sequence

    <?xml version="1.0" encoding="UTF-8"?>
<sequence name="EmailSend_SEQ" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <payloadFactory media-type="xml">
        <format>
            <ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:text>
        </format>
        <args>
            <arg evaluator="xml" expression="get-property('emailBodyWithRec')"/>
        </args>
    </payloadFactory>
    <property value="Sample Email" name="Subject" scope="transport" type="STRING"/>
    <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
    <property name="messageType" scope="axis2" type="STRING" value="text/html"/>
    <property name="ContentType" scope="default" type="STRING" value="text/html"/>
    <property name="transport.mail.Format" scope="axis2" type="STRING" value="Attachment"/>
    <property expression="get-property('sAttachmentFileName')" name="AttachmentFile" scope="axis2" type="STRING"/>
    <header expression="fn:concat('mailto:', get-property('primaryEmail'))" name="To" scope="default"/>
    <call/>
    <property name="OUT_ONLY" scope="default" type="STRING" value="false"/>
    <payloadFactory media-type="xml">
        <format>
            <EmailNotificationResponse>
                <Status xmlns="">SUCCESS</Status>
            </EmailNotificationResponse>
        </format>
        <args/>
    </payloadFactory>
</sequence>

HTML Content :

<html xmlns="http://ws.apache.org/ns/synapse" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <head>
      <meta content="width=device-width, initial-scale=1.0" name="viewport"/><style>table, td, th {   border: 1px solid black;}table {  text-align: center;    border-collapse: collapse;   font-weight:bold}td { width: 140px;}</style></head>
   <body>
      <table>
         <tr>
            <th>Transactions Processed</th>
            <td>1111110</td>
         </tr>
         <tr>
            <th>Success</th>
            <td>0</td>
         </tr>
         <tr>
            <th>Expired</th>
            <td>0</td>
         </tr>
         <tr>
            <th>Failed</th>
            <td>0</td>
         </tr>
      </table>
   </body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文