• Post Reply Bookmark Topic Watch Topic
  • New Topic

Extract Message Object from Original Message which is not MIME  RSS feed

Zachary Buckholz
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am parsing an email message body and extracting another message from it which is a string in memory. I need to take this string which may or may not be a Mime formatted message and create a new Message object.

The API says I can create a new message object using an InputStream, but I am not sure how to do this. This is my current snippet.

for (int i = 0; 1 < msgs.length; i++) {
System.out.println("MESSAGE # " + (i + 1) + ":");
String messageString = msgs[i].getContent().toString().replaceFirst("-------- Original Message --------","");

StringReader sr = new StringReader(messageString);
InputStream is = sr.read(); <-- what do I do here?

Message nm = new MimeMessage(session, is);
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!