I am trying to move from Javamail to mime4j in the hope of having less trouble parsing mail. However I haven't managed to find out how to connect to a mail server to then use mime4j to parse messages.
Javamail provides session and connections to a mail server via IMAP or POP3 from which you then read Messages. As far as I can tell mime4j does not offer anything equivalent.
So how can I connect to mail servers to use mime4j? Can I use Javamail in conjunction with mime4j?
I have tried using the javamail Message.getInputStream
method to get an input stream that I pass to mime4j's DefaultMessageBuilder.parseMessage
. However the result is not what I expect: for a multipart message containing a plain text part and an html part, only one TextBody is created. I suspect this is because the DefaultMessageBuilder.parseMessage
is expecting a stream for the whole message, not just the body, but that javamail Message.getInputStream
only provides the body.
In fact, I'm only interested in the body, since this is what was causing problems with Javamail, but parsing the whole message (if I could get it as an input stream form Javamail) would do just as well.
Any help greatly appreciated!