I have a Java Maven project and I use org.apache.camel
to obtain mail and attachment information.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mail</artifactId>
<version>2.17.0</version>
</dependency>
Given an Exchange
object I use this code to get the attachments:
Message message = exchange.getIn().copy();
message.getAttachments()
Where messageCopy.getAttachments()
returns a Map<String, DataHandler>
that maps attachment-file-Name
to DataHandler
.
This code works when the mail has a single attachment or attachments that are named differently. When I have two attachments with the same name it follows that, due to the map structure, only one is returned (the other is simply overwritten).
Does anyone have the same problem and/or know another method to get two (or more) homonymous attachments?
Thanks