Saturday, December 14, 2019

Attachment-file Email in WSO2 ESB

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="fault_email" xmlns="http://ws.apache.org/ns/synapse">
    <clone continueParent="true" sequential="false">
        <target>
            <sequence>
                <property name="To" scope="transport" type="STRING" value="xxxx@gmail.com, XXXXXX@quinnox.com"/>
                <property expression="get-property('SERVER_HOST')"
                    name="ServerHost" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
                <property
                    expression="fn:concat('[', $ctx:ServerHost ,']')"
                    name="environment" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
                <property
                    expression="fn:concat($ctx:environment, ' An Error Occurred Service : ',$ctx:proxy.name)"
                    name="Subject" scope="transport" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
                <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
                <property name="transport.mail.Format" scope="axis2"
                    type="STRING" value="Attachment"/>
                <property name="AttachmentFile" scope="axis2"
                    type="STRING" value="ErrorMessage.xml"/>
                <property expression="$ctx:messageBody"
                    name="transport.mail.bodyWhenAttached" scope="axis2"
                    type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
                <header action="remove" name="To" scope="default"/>
                <property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
                <property name="RESPONSE" scope="default" type="STRING" value="true"/>
                <property name="ContentType" scope="axis2" type="STRING" value="text/html"/>
                <property name="messageType" scope="axis2" type="STRING" value="text/html"/>
                <send>
                    <endpoint>
                        <address uri="mailto:"/>
                    </endpoint>
                </send>
            </sequence>
        </target>
    </clone>
</sequence>

----------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="fault_email" xmlns="http://ws.apache.org/ns/synapse">
    <clone continueParent="true" sequential="false">
        <target>
            <sequence>
                <property name="To" scope="transport" type="STRING" value="manohar.850@gmail.com, manoharam@quinnox.com"/>
                <property name="Cc" scope="transport" type="STRING" value="manohar.850@gmail.com, manoharam@quinnox.com"/>
                <property expression="get-property('SERVER_HOST')"
                    name="ServerHost" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
                <property
                    expression="fn:concat('[', $ctx:ServerHost ,']')"
                    name="environment" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
                <property
                    expression="fn:concat($ctx:environment, ' An Error Occurred Service : ',$ctx:proxy.name)"
                    name="Subject" scope="transport" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
                <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
                <property name="transport.mail.Format" scope="axis2"
                    type="STRING" value="Attachment"/>
                <property name="AttachmentFile" scope="axis2"
                    type="STRING" value="ErrorMessage.xml"/>
                <property expression="$ctx:messageBody"
                    name="transport.mail.bodyWhenAttached" scope="axis2"
                    type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
                <header action="remove" name="To" scope="default"/>
                <property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
                <property name="RESPONSE" scope="default" type="STRING" value="true"/>
                <property name="ContentType" scope="axis2" type="STRING" value="text/html"/>
                <property name="messageType" scope="axis2" type="STRING" value="text/html"/>
                <property name="FORCE_ERROR_ON_SOAP_FAULT"
                    scope="default" type="STRING" value="true"/>
                <payloadFactory media-type="xml">
                    <format>
                        <Fault>
                            <ERROR_CODE>$1</ERROR_CODE>
                            <ERROR_MESSAGE>$2</ERROR_MESSAGE>
                            <ERROR_DETAIL>$3</ERROR_DETAIL>
                        </Fault>
                    </format>
                    <args>
                        <arg evaluator="xml"
                            expression="get-property('ERROR_CODE')"
                            literal="false" xmlns:ns="http://org.apache.synapse/xsd"/>
                        <arg evaluator="xml"
                            expression="get-property('ERROR_MESSAGE')"
                            literal="false" xmlns:ns="http://org.apache.synapse/xsd"/>
                        <arg evaluator="xml"
                            expression="get-property('ERROR_DETAIL')"
                            literal="false" xmlns:ns="http://org.apache.synapse/xsd"/>
                    </args>
                </payloadFactory>
                <send>
                    <endpoint>
                        <address uri="mailto:"/>
                    </endpoint>
                </send>
            </sequence>
        </target>
    </clone>
</sequence>


No comments:

Post a Comment