email attachment count

hello java guru's

can someone tell me how will i get all the attachments(>2) and print each attachments content..

part = new Packages.javax.mail.internet.MimeBodyPart(is);

for each of the attachment, i want the filename, filecontent in a sort of array or something like vector...content is ascii text not images or html....

any sample code will help alot.. i tried but all my efforts are unsuccessful.

thanks

[457 byte] By [mrweb24] at [2007-9-26 1:35:12]
# 1

I think maby this helps:

MimeMultipart mmp = message.getContent();//Make sure you can get Message object(message) from Folder object

String[] fileName;

String[] content;

int partCount = mmp.getCount();

fileName = new String[partCount -1];

content = new String[partCount -1];

int index = 0;

for(int i = 0;i < partCount;i ++){

BodyPart bp = new BodyPart();

bp = mmp.getBodyPart(i);

if(bp.isMimeType("text/html")){

...........

}

if(bp.isMimeType("text/plain")){

...........

}

else{//Here is attachment

fileName[index] = bp.getFileName();

javax.activation.DataHandler dh = bp.getDataHandler();

content[index] = (String)dh.getContent();

}

}

metalcure at 2007-6-29 2:19:16 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...