You need to understand the structure of MIME messages. Not all message will be multipart messages. These JavaMail FAQ entries might help:
That is fine. But my case is, both the mails have text and images in the body but not attachments explicitly. And when I use IMAP without SSL certificate, I am able to get the content for both the mails and type of both the mails is "multipart". But when I use IMAP with SSL, one mail has its type as "multipart" and the other has "text/html". So when it is "text/html", I tried getting it through "InputStream". Even that didn't work. Basically its content is empty.
I need a lot more details to help you. If you don't want to post those details here, send them to me at email@example.com.
I'm highly skeptical that you're getting different behavior depending on whether or not you use SSL to connect to the same mail server and view the same message. Are you actually using different mail servers? Are you looking at different messages?
You need to explain what it means to have text and images in the body but not as attachments. Do you have an example?
In the case where you tried to get the content of the message but you got nothing, what does the protocol trace show? (Turn on JavaMail Session debugging.) What code are you using to get the message content? If you use the msgshow.java sample program, is it able to get the message content?
Yes. I am connecting to the same mail server and trying to view the same message.
And when I say "text and images in body but not as attachments", I mean to say that mail body contains some text, images, screen shots, hyperlinks etc. And mail doesn't have any attachments.
And when I tried to debug and see the result, I saw the content as nothing (empty string, "").
This is to confirm you with these details. I'll come back with the example mail and sample code I've used.
Sent it again. The mail contains the sample code in body. And an attachment which is the "sample email". The sample email was edited by me. I have changed some data and screen shots but the format is same, with which I was facing the issue.
Please let me know if you don't get the mail.
sent the mail to: firstname.lastname@example.org
with Subject : Required data for the Discussion:https://community.oracle.com/thread/3539595
Thanks for the help on this request. We got to know the solution after working with the sample program.
I need some clarification. From the documentation here: http://docs.oracle.com/javaee/5/api/javax/mail/FetchProfile.Item.html
I found that "CONTENT_INFO" profile is used to get information about the content of the message. This is where we got the problem. When I set this value, I am not getting content for mails without attachments. When I remove this, I am able to get content for all mails.
My question is "How can I prevent the program from fetching the content and attachments? Can I have a single tag like this or should I use separate tags?"
And what is the expected behavior of "CONTENT_INFO" profile?
Can I get some help on this?
I am using jdk version 1.7 and java mail version 1.4.7.
CONTENT_INFO doesn't fetch any content. In IMAP terms, it fetches the BODYSTRUCTURE for the message.
Can you explain in more detail what it is you're doing, what happens, and what you expect to happen? Please include the debug output showing the problem.
Also, you might want to consider upgrading to the current version of JavaMail - 1.5.2.