T
Tajonis
I am having some issues when using Javamail and an IMAP folder. I am
trying to check for an IMAP folder for specific messages (this part is
working great). When I notice a message I am interested in I begin to
process the message and hopefully save the contents to disk. What I am
seeing is that if the message is a multipart/alternative message my
applications processes the message but the resulting file(s) are all
empty. Here is my method that is handling the multipart messages
private void processMultpartMessage(Multipart part,String filename)
throws MessagingException,IOException{
ArrayList contents = new ArrayList();
for(int index = 0; index < part.getCount(); index++){
BodyPart bodyPart = part.getBodyPart(index);
Object content = bodyPart.getContent();
InputStream input = bodyPart.getInputStream();
byte[] contentArray = new byte[input.available()];
input.read(contentArray);
contents.add(contentArray);
input.close();
}
int partCounter = 1;
if(!contents.isEmpty()){
Iterator iterator = contents.iterator();
while(iterator.hasNext()){
byte[] content = (byte[])iterator.next();
writePartToFile(filename,content,partCounter);
partCounter++;
}
}
}
Is there something I am missing here or am I just stoopid ;-)
As a side note this all works fine if I am using a POP folder to
recieve mail.
trying to check for an IMAP folder for specific messages (this part is
working great). When I notice a message I am interested in I begin to
process the message and hopefully save the contents to disk. What I am
seeing is that if the message is a multipart/alternative message my
applications processes the message but the resulting file(s) are all
empty. Here is my method that is handling the multipart messages
private void processMultpartMessage(Multipart part,String filename)
throws MessagingException,IOException{
ArrayList contents = new ArrayList();
for(int index = 0; index < part.getCount(); index++){
BodyPart bodyPart = part.getBodyPart(index);
Object content = bodyPart.getContent();
InputStream input = bodyPart.getInputStream();
byte[] contentArray = new byte[input.available()];
input.read(contentArray);
contents.add(contentArray);
input.close();
}
int partCounter = 1;
if(!contents.isEmpty()){
Iterator iterator = contents.iterator();
while(iterator.hasNext()){
byte[] content = (byte[])iterator.next();
writePartToFile(filename,content,partCounter);
partCounter++;
}
}
}
Is there something I am missing here or am I just stoopid ;-)
As a side note this all works fine if I am using a POP folder to
recieve mail.