'WSO2 EI6.6 : Send email with attachment and HTML body

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>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source