SMTP subject expression evaluation fails

637 views Asked by At

I have a flow where I want to evealuate an expression on the smtp subject attribute but always get mvel parse expression though the logger give me the right values.

<json:object-to-json-transformer doc:name="Object to JSON"/>
<logger message="MYRequestPayloadID #[json:RequestPayloadID] #[json:ResponseStatusCd]" level="DEBUG" doc:name="Logger"/>       
<smtp:outbound-endpoint host="${mail.host}" to="${mail.to}" from="${mail.from}" subject="Error Response for PayloadID #[json:RequestPayloadID], Status #[json:ResponseStatusCd]" responseTimeout="10000" doc:name="SMTP />

I am not sure why in the subject #[json:RequestPayloadID] and #[json:ResponseStatusCd] evaluation fail though I get the data back in the logger . Thanks.

1

There are 1 answers

0
David Dossot On BEST ANSWER

Expressions are not supported everywhere in Mule (alas): this is one place where it isn't.

You have to use message properties to set the subject dynamically:

<set-property propertyName="subject"
     value="Error Response for PayloadID #[json:RequestPayloadID], Status #[json:ResponseStatusCd]" />

FTR json: is the old expression style, nowadays you should be using MEL instead: http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+Tips#MuleExpressionLanguageTips-JSONProcessing