質問

Obviously this is in Java. I've set up a camel route to an SMTP route, but I want the subject of the mail to be dynamic and based on the input message it received

e.g. subject "Line 52 is down"

The body of the email is fine and appears perfectly. But I can't seem to set the subject of the email, it always gets received as 'no subject'

In the Camel Processor I use

Message msg = exchange.getOut();

// This works perfectly
msg.setBody( "Some body stuff " + lineProblem + " and some other details"); 

// PROBLEM - This has no effect (the order of the statements has no effect)
msg.setHeader( "Subject", " line " + lineProblem + " is down" );

but it's always received in the inbox as 'no subject'

I can see other ways to set the subject, both at the endpoint level and at the route level, but of course neither of these will let me set the subject at a message-level

any ideas?

役に立ちましたか?

解決 2

Essentially there is one subject per Exchange, so if you need different subjects on each email, use a splitter to handle each email as a separate exchange individually

他のヒント

try exchange.getIn().setHeader(...) as the Producer/Binding iterates over the IN message headers to populate the subject, etc.

see the MailBinding.appendHeadersFromCamelMessage() code for more information:

https://svn.apache.org/repos/asf/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top