I have an email that I need to process in mule with roughly the following structure, with a multipart/mixed wrapping a multipart/alternative, which in turn has two parts:
Message-ID: <113093521.2.1380303746136.JavaMail.admin-gmsharpe@PSL-GSHARPE>
Subject: MultiPart Mail
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_1336225759.1380303746093"
X-Virus-Scanned: clamav-milter 0.97.8 at msa3
X-Virus-Status: Clean
X-Scanned-By: MIMEDefang 2.74
------=_Part_0_1336225759.1380303746093
Content-Type: multipart/alternative;
boundary="----=_Part_1_2021372560.1380303746102"
------=_Part_1_2021372560.1380303746102
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
This is multipart mail and u read part1......
------=_Part_1_2021372560.1380303746102
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
This is multipart mail and u read part2......
------=_Part_1_2021372560.1380303746102--
------=_Part_0_1336225759.1380303746093--
I'm trying to get at either the text/plain or text/html content body. In my flow I have something like the following (stripped out irrelevant content).
<expression-transformer name="returnAttachments">
<return-argument evaluator="attachments-list" expression="*" optional="false"/>
</expression-transformer>
<flow name="imap-flow" doc:name="imap-flow">
<imaps:inbound-endpoint host="${mail.host}" port="${mail.port}" user="${user}" password="${password}" responseTimeout="10000" doc:name="IMAP" connector-ref="IMAPS" transformer-refs="returnAttachments" disableTransportTransformer="true"/>
<collection-splitter/>
<component class="<package name>.EmailTransformer" doc:name="EmailTransformer"/>
..... Rest of flow ....
</flow>
In the EmailTransformer class I am attempting to get at what I hope is the entire nested structure of attachments in the MultiPart Email:
private String getRelevantEmailBodyContent(MuleMessage message) throws Exception {
DataHandler handler = (DataHandler)message.getPayload();
MimePartDataSource mimePartDataSource = (MimePartDataSource)handler.getDataSource();
... Not sure what to do next.
}
Looking at the contents of what is contained in the MimePartDataSource in the code above, I'm not sure that the Mule IMAP connector has grabbed more than the two levels in the email: multipart/mixed and its child multipart/alternative. I don't think it has actually grabbed the two subparts of multipart/alternative. Can anyone confirm this? If the Mule IMAP component does not in fact grab anything beyond the two levels, I suspect that there's nothing I can do short of customizing parts of the Mule IMAP Endpoint, MessageReceiver, etc. ....