aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Extract Message Object from Original Message which is not MIME Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Extract Message Object from Original Message which is not MIME" Watch "Extract Message Object from Original Message which is not MIME" New topic
Author

Extract Message Object from Original Message which is not MIME

Zachary Buckholz
Greenhorn

Joined: Sep 21, 2005
Posts: 1
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("--------------------------");
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);
 
 
subject: Extract Message Object from Original Message which is not MIME