Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IMAP Attachment  RSS feed

Stone Yen
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to save the attachment of a email with the javamail api.
when i use pop3 to connect to server, everything is fine.
I can get the attachment files.
However, if i use imap to connect to server, i can only get the file name.
I cannot get the file.
follow is the code segment i used for retrieving the attachment.
1: Part p=mp.getBodyPart(partNum);
2: InputStream inputStream = p.getInputStream();
3: att = new byte[inputStream.available()];
4: int readBytes =;

in line 3, the inputStream.available() always return 0;

thank you for your help.
Best regards
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!