Question

i am using mail transport and i have done the changes in axis2 file and my esb ruining fine with mail but my issue is its not sending properr format i wish to send body also but its just sending "Subject" my config like this

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="StaticMail"
       transports="http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence>
         <property name="senderAddress"
                   expression="//mail/text()"
                   scope="default"/>
         <property name="Subject" value="Alert:Reading Out of Range" scope="transport"/>
         <property name="message" value="Response message" scope="transport"/>
         <property name="body" expression="//list/text()" scope="default"/>
         <header name="To"
                 expression="fn:concat('mailto:', get-property('senderAddress'))"/>
         <property name="OUT_ONLY" value="true"/>
         <log level="full">
            <property name="message" value="Response message"/>
            <property name="Sender Address" expression="get-property('senderAddress')"/>
         </log>
         <send/>
      </inSequence>
      <outSequence/>
   </target>
</proxy>

but its sending mail format like this only

Alert:Reading Out of Range as a Subject there is nobody for mail and one empty attachment with"noname" how we can send a mail with proper body please let me know

Was it helpful?

Solution

You can do this using Script Mediator a sample is here

Here is another example which sends the error message as the email body and error code as the subject. Here payload factory is used instead of script mediator.

<faultSequence>
     <property xmlns:ns="http://org.apache.synapse/xsd" name="ErrorCode" expression="get-property('ERROR_CODE')" scope="default" type="INTEGER"/>
     <property name="ErrorMessage" expression="get-property('ERROR_MESSAGE')" scope="default" type="STRING"/>         
     <property name="messageType" value="text/html" scope="axis2"/>
     <property name="ContentType" value="text/html" scope="axis2"/>
     <property xmlns:ns="http://org.apache.synapse/xsd" name="Subject" expression="$ctx:ErrorCode" scope="transport"/>
     <payloadFactory>
        <format>
           <ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:text>
        </format>
        <args>
           <arg expression="$ctx:ErrorMessage"/>
        </args>
     </payloadFactory>
     <property name="OUT_ONLY" value="true"/>
     <send>
        <endpoint>
           <address uri="mailto:youremail@gmail.com"/>
        </endpoint>
     </send>
  </faultSequence>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top