使用wso2发送带有正文的电子邮件

时间:2013-07-19 11:10:46

标签: wso2 rhino

我是wso2的新手。我使用this代码,它发送电子邮件确定,但我怎样才能修改电子邮件的正文? ESB发送带有主题的电子邮件,但身体空白且没有附件。我一直在wso2文档中查看有关如何设置电子邮件正文的信息,但我一无所获。

我尝试使用脚本调解器,就像在this样本中一样,但它给了我下一个例外:

Caused by: org.mozilla.javascript.EvaluatorException: Can't find method org.apache.synapse.mediators.bsf.ScriptMessageContext.setPayloadXML(). (<Unknown Source>#1)
    at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
    at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1030)
    at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1086)
    at org.mozilla.javascript.Context.reportRuntimeError1(Context.java:1049)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:162)
    at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
    at org.mozilla.javascript.gen.c4._c0(<Unknown Source>:1)
    at org.mozilla.javascript.gen.c4.call(<Unknown Source>)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
    at org.mozilla.javascript.gen.c4.call(<Unknown Source>)
    at org.mozilla.javascript.gen.c4.exec(<Unknown Source>)
    at com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:55)
    ... 15 more

我正在使用wso2 4.7.0。谁能帮我?感谢。

1 个答案:

答案 0 :(得分:0)

在下面的代理中,我已经对身体进行了参数化。它对我来说很好

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="MailToTransportSenderBCC"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="emailSubjectToSent"
                   expression="//emailSubject"
                   scope="default"
                   type="STRING"/>
         <property name="emailMassegeToSent"
                   expression="//emailMassege"
                   scope="default"
                   type="STRING"/>
         <property name="Subject"
                   expression="get-property('emailSubjectToSent')"
                   scope="transport"/>
         <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
         <property name="ContentType" value="text/plain" scope="axis2"/>
         <property name="messageType" value="text/plain" scope="axis2"/>
         <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('emailMassegeToSent')"/>
            </args>
         </payloadFactory>
         <send>
            <endpoint>
               <address uri="mailto:receiver@gmail.com"/>
            </endpoint>
         </send>
         <header name="To" action="remove"/>
         <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
         <property name="RESPONSE" value="true" scope="default" type="STRING"/>
         <send/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="MailToTransportSenderBCC" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <property name="emailSubjectToSent" expression="//emailSubject" scope="default" type="STRING"/> <property name="emailMassegeToSent" expression="//emailMassege" scope="default" type="STRING"/> <property name="Subject" expression="get-property('emailSubjectToSent')" scope="transport"/> <property name="OUT_ONLY" value="true" scope="default" type="STRING"/> <property name="ContentType" value="text/plain" scope="axis2"/> <property name="messageType" value="text/plain" scope="axis2"/> <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('emailMassegeToSent')"/> </args> </payloadFactory> <send> <endpoint> <address uri="mailto:receiver@gmail.com"/> </endpoint> </send> <header name="To" action="remove"/> <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/> <property name="RESPONSE" value="true" scope="default" type="STRING"/> <send/> </inSequence> <outSequence> <send/> </outSequence> </target> <description/> </proxy>