get Emailcontent from PSTMessage

104 views
Skip to first unread message

Florian Pohl

unread,
Sep 3, 2014, 9:41:22 AM9/3/14
to java-libp...@googlegroups.com
Hey there,

i'm going through my pst-File and have my emails in the PSTMessage Object.

Everything works fine and i like this library very much! 

But I just can't find a method which return me just the email content! ... I have the Subject, the Sender, the Recepient mail addresses, Date and everything I need, but I can't find a way to simply gain the email content.

I found getBody(), but this returns more than the only the text. I don't want to workaround with this method, because i'm sure there must be a simple way to find the emailcontent with the information auf getBody(), which i don't need.


Sorry in advance for this simple question, but i'm despairing with this :(

Richard Johnson

unread,
Sep 3, 2014, 9:59:33 AM9/3/14
to java-libpst-discuss
So I think what you might be looking at is the raw text for a mime-encoded (http://en.wikipedia.org/wiki/MIME) email.  Have you tried feeding it into something like http://docs.oracle.com/javaee/1.4/api/javax/mail/internet/MimeUtility.html#decodeText(java.lang.String) ?


--
You received this message because you are subscribed to the Google Groups "java-libpst-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-libpst-dis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Florian Pohl

unread,
Sep 3, 2014, 10:20:29 AM9/3/14
to java-libp...@googlegroups.com
I just want the written content from the emails (PSTMessage). I have not tried this solution, because i thought it would be possible with this library. With getBody() I get this content, but also other information and data i don't need at this point. That's why I asked here.

What should i decode in your opinion? And what should i feed into it? The PSTMessage Object ?

I thought, the PSTMessage Object itself could returns me the content



Richard Johnson

unread,
Sep 3, 2014, 10:49:11 AM9/3/14
to java-libpst-discuss
The library attempts to give you what is stored in the PST file.  If the email is mime-encoded (as most are these days) I believe outlook extracts the email contents from what is returned in getBody and attempts to populate getBodyHTML or getRTF with the contents it chooses to display.

Mime is standard encoding for emails with multiple "parts", one of which should be the plain text you are after.  What I thought I was linking you to was a utility to extract out these parts, however I stuffed up.  You should however be able to use the java mail api to do something like: Message msg = new MimeMessage(mySession, new ByteArrayInputStream(msg.getBody().getBytes()));

... though you might find it easier simply splitting the string on the mime boundaries and stripping off the content headers.



Florian Pohl

unread,
Sep 4, 2014, 10:45:11 AM9/4/14
to java-libp...@googlegroups.com
OK Thanks for your help! getBody() was fine. I was a little bit wrong with my question. 
To unsubscribe from this group and stop receiving emails from it, send an email to java-libpst-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages