• Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaMail - Construct a MimeMessage from a text file  RSS feed

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I've written some code that connects to the mail server, opens a certain inbox, retrieves the message(s) and writes them to an output stream. Limiting my code to that last bit:



So now, if I were to actually save each message to an individual text file, I'd get (according to the javadoc) "the message as an RFC 822 format stream".

I then tried to find the message.readFrom(InputStream is) method, and did not find one. There's something that looks promising on the MimeMultipart class (a parse() method) but it (and other methods like it) are all protected. So, I'm not very familiar with this API other than using it to send email. Does anyone know then, how to use it as if I were a mailserver, reading a mailfile off disk?

What I eventually want to do: Make an exact copy of a certain message that I've got in an inbox. This particular message, which is from an external 3rd party, exhibits problems for software further down the line that reads and deletes the message from the inbox. I'd simply like to be able to reliably re-produce this exact message with all its problems. I've had no success constructing my own messages using the JavaMail API, that duplicates the exact nature of this message (which is why I thought to make a copy of it).
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about the constructors of MimeMessage? You'll need a Session, but that shouldn't be a problem.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Talk about not seeing the tree for the forest.

Thanks, that works dandy.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!