Reading MimeMultipart question
1 posts in topic
Flat View  Flat View

Posted By:   Kevin_Cox
Posted On:   Monday, August 27, 2001 12:19 PM

When I use the getContent() to read messages, it works fine for some, but others I just get MimeMultipart displayed. How can I get those messages to display(without the writeTo function). My goal is to be able to write the getContent to a txt file, which works fine for everything but the MimeMultipart messages. I've been reading every tutorial I can find, but they don't seem to cover this one. Thanks for reading.

Re: Reading MimeMultipart question

Posted By:   fernando_fernandes  
Posted On:   Monday, September 3, 2001 01:56 PM

You have to go throw every part of the Multipart Message. There are many types of parts. Something like this:

private boolean processParts (Part part) throws Exception{
Object o = part.getContent();
if (o instanceof Multipart) {
Multipart mp = (Multipart) o;
int count = mp.getCount();
for (int i = 0; i < count; i++){
if (!processParts (mp.getBodyPart(i))){
return false;
} else if (o instanceof InputStream){
//Save the InputStream
} else if (o instanceof Message){
if (!processParts ((Message)o)){
return false;
return true;

You may call this function like this:

processParts (message[iMsg]);

Something like that!
I found it in the "JavaMail API Design Specification Version 1.2" in the website!
About | Sitemap | Contact