Did you ever used MessageTransformBean to set a static name to your attachment?
Finally, did you ever wanted to make it a little more dynamic?
If the answer to the above questions is yes then you should consider trying creating
an adapter module that will enable you to set the attachment’s name dynamically.
It’s rather easy as you can do a simple functionality with just a few lines of code.
In this weblog I’ll try to provide a simple solution which will take an XML tag’s name
from the modules Tab configuration and will set our attachment’s name
from the value found inside this XML tag.
Have a look at the code below:
Let’s prepare a test XML file which we’ll try to send as our attachment.
The last thing we have to set is the configuration in the communication channel – Modules – tab for our adapter module.
Now we test our scenario and if we did everything correctly we should see a new e-mail message with the weblog.xml attachment.
As you can see this weblog provides only a simple solution which can be extended in many ways:
– removing the tag that holds the attachment’s name
– converting the attachment to some other formats (not only xml)
– and many other things