wieseljonas / java-libpst

Automatically exported from code.google.com/p/java-libpst
1 stars 1 forks source link

Mail as an attachment - issue #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a new pst with 1 mail. 
2. Have 2 attachments in the mail. (abc.msg, 123.pdf)
3. The 1st attachment is MSG file which has attachment (456.pdf). 

What is the expected output? What do you see instead?
The attachment count should be 2 (abc.msg, 123.pdf)

Instead, we get 1 (123.pdf)

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by manish.b...@gmail.com on 1 Feb 2011 at 10:18

GoogleCodeExporter commented 9 years ago
Yeah, there's something weird when we get to .msg attachments.

They are not actually stored as attachments in the PST, but as some kind of 
embedded message.

I can't remember exactly how to get at them, I will have a bit of a look and 
get back to you.

Thanks,

Richard

Original comment by rjohnson...@gmail.com on 1 Feb 2011 at 10:47

GoogleCodeExporter commented 9 years ago
Its not only MSG attachments. There is an API in 
PSTAttachment(getEmbeddedPSTMessage) to get embedded pst message. But it is not 
working properly. Moreover if the msg file itself has an attachment, then the 
whole extraction fails. 

Original comment by manish.b...@gmail.com on 1 Feb 2011 at 12:12

GoogleCodeExporter commented 9 years ago
Had a quick look & could replicate the issue, but I can't see any immediate 
resolution.

I need to have a dig around and find out where the attachment might be hiding.  
The issue is it's not appearing in the usual attachment 7c table, I would be 
expecting an entry there even for embedded attachments :/

Richard

Original comment by rjohnson...@gmail.com on 1 Feb 2011 at 2:32

GoogleCodeExporter commented 9 years ago
Hi, 
Can you give me pointers where to look at, so that even i can dig into the code 
and try to fix it. 

Also, when i see 7c table, i find the attachment name present there. Might be 
we are not generating the right attachmentTable. 

Original comment by manish.b...@gmail.com on 2 Feb 2011 at 3:50

GoogleCodeExporter commented 9 years ago
Sure!

You can grab the published microsoft documentation here: 
http://msdn.microsoft.com/en-us/library/ff385210(v=office.12).aspx

And there is a lot of good stuff in the LibPFF reverse engineering project 
here: http://sourceforge.net/projects/libpff/files/

The microsoft document will probably be the most useful, there is some stuff 
there on page 84 which looks like it will point us in the right direction.

Please let me know if you make any progress, and I'll try to look at it shortly.

Thanks,

Richard

Original comment by rjohnson...@gmail.com on 2 Feb 2011 at 10:03

GoogleCodeExporter commented 9 years ago
Okay, I've made some progress with this.

When we get a listing of attributes (PSTDescriptorItems) for a PST message, I 
found that some attributes have sub-attributes.  Not knowing exactly when to 
intelligently use the sub-items or not, I read all items into the same lookup 
(localDescriptorItems) table.

What is happening here is that the first message's attachment table is being 
clobbered by the embedded attachment table used by the attached .msg file.  You 
can comment out the lines 80ish in PSTDescriptor.java, and that will give you 
the correct attachment table, however this will break the ability to retrieve 
the attachment, as it uses some of the sub-attributes.

I will continue to try and work out when to use the sub-items and hopefully 
correct this properly.

Original comment by rjohnson...@gmail.com on 2 Feb 2011 at 8:56

GoogleCodeExporter commented 9 years ago
Okay, I've managed to get a fix into SVN which will hopefully address this 
(more) correctly.

This changes things a bit, so tread carefully! I didn't really have time to 
check this thoroughly, so please don't hate me if you run into additional 
issues (but please tell me of them).

Kind Regards,

Richard

Original comment by rjohnson...@gmail.com on 2 Feb 2011 at 11:35

GoogleCodeExporter commented 9 years ago
Hi Richard, 
Thanks for the quickest response. 

I did a quick test and it seems that it is working properly. I will be testing 
with more psts and ensure that nothing breaks. 

But, it is throwing issues in this scenario, if a mail has 2 embedded mails, 
then we are running into issues. 

Thanks and Regards,
Manish. 

Original comment by manish.b...@gmail.com on 3 Feb 2011 at 4:58

GoogleCodeExporter commented 9 years ago
I am getting 2 issues, not able to identify when i am getting those. 
com.pff.PSTException: Unable to find node: 0
    at com.pff.PSTFile.findBtreeItem(PSTFile.java:661)
    at com.pff.PSTFile.getOffsetIndexNode(PSTFile.java:689)
    at com.pff.PSTFile.readLeaf(PSTFile.java:429)
    at com.pff.PSTFile.getPSTDescriptorItems(PSTFile.java:699)
    at com.pff.PSTMessage.getAttachment(PSTMessage.java:874)

java.lang.NullPointerException
    at com.pff.PSTTable7C.<init>(PSTTable7C.java:117)
    at com.pff.PSTTable7C.<init>(PSTTable7C.java:30)
    at com.pff.PSTMessage.processAttachments(PSTMessage.java:767)
    at com.pff.PSTMessage.getNumberOfAttachments(PSTMessage.java:822)

Original comment by manish.b...@gmail.com on 3 Feb 2011 at 6:44

GoogleCodeExporter commented 9 years ago
Hi Manish,

1 step forward, 1 step back....

I'll try and replicate this sometime today and get back to you.

Kind Regards,

Richard

Original comment by rjohnson...@gmail.com on 3 Feb 2011 at 10:03

GoogleCodeExporter commented 9 years ago
But, one good thing, the embedded mails are working properly. Also, if embedded 
mails have attachment, its working properly. I dont know when we are getting 
this NullPointerException. 

Original comment by manish.b...@gmail.com on 3 Feb 2011 at 2:58

GoogleCodeExporter commented 9 years ago
okay, try that out.

Basically, I believe not all attachments need have a 
subNodeOffsetIndexIdentifier.

Original comment by rjohnson...@gmail.com on 3 Feb 2011 at 5:31

GoogleCodeExporter commented 9 years ago
Still getting this, 
java.lang.NullPointerException
    at com.pff.PSTTable7C.<init>(PSTTable7C.java:118)
    at com.pff.PSTTable7C.<init>(PSTTable7C.java:32)
    at com.pff.PSTMessage.processAttachments(PSTMessage.java:767)
    at com.pff.PSTMessage.getNumberOfAttachments(PSTMessage.java:822)

java.lang.NullPointerException
    at com.pff.PSTTable7C.<init>(PSTTable7C.java:118)
    at com.pff.PSTTable7C.<init>(PSTTable7C.java:32)
    at com.pff.PSTMessage.processRecipients(PSTMessage.java:715)
    at com.pff.PSTMessage.getNumberOfRecipients(PSTMessage.java:735)

Original comment by manish.b...@gmail.com on 4 Feb 2011 at 4:24

GoogleCodeExporter commented 9 years ago
okay, it definitely needs some of these descriptor items.

Can you post me a PST to test with?

Original comment by rjohnson...@gmail.com on 4 Feb 2011 at 10:01

GoogleCodeExporter commented 9 years ago
okay, I think my last round of fixes addressed this issue, I've created an 
email with two embedded messages, both with attachments and it appears I can 
get to all the attachments including those in the embedded messages.

Please have another look over it and let me know if you continue to come across 
any issues.

Original comment by rjohnson...@gmail.com on 2 Apr 2011 at 12:46