0

我是wso2的新手。我使用了这个代码,它可以发送电子邮件,但是我怎样才能修改电子邮件的正文?ESB 发送带有主题但正文为空且没有附件的电子邮件。我一直在查看 wso2 文档中有关如何设置电子邮件正文的信息,但我什么也没找到。

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

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。谁能帮我?谢谢。

4

1 回答 1

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>

于 2015-03-10T08:50:29.780 回答