I'm trying to extract PST files using java-libpst-0.8.1 , following https://code.google.com/p/java-libpst/
In my sample pst file, there are several mails. In one of the mail of that pst file, the attachment is also a mail. While parsing that PSTMessage
, it's not able to fetch even, attachment's name. Please find the sample code.
PSTMessage email;
PSTAttachment attach;
email = (PSTMessage) folder.getNextChild();
while (email != null) {
try {
numberOfAttachments = email.getNumberOfAttachments();
if (numberOfAttachments > 0) {
for (int x = 0; x < numberOfAttachments; x++) {
attach = email.getAttachment(x);
try {
attachmentName = attach.getLongFilename();
Though the program is giving the exact count of the mail's attachments. But it's not able to provide, the attached mail's name or extracting it's content. Can anyone suggest a way what should I do?
Finally, I'm able to read the mail which is an attachment of a mail. There is a method getEmbeddedPSTMessage()
in PSTAttachment
class. First I need to check whether it's a normal attachment or a mail. For that we need to refer getAttachMethod()
. If it returns 5
it's an embedded message. For details, please check out the documentation of PSTAttachment
.
if (attach.getAttachMethod() == 5) {
PSTMessage attachEmail = attach.getEmbeddedPSTMessage();
}