wieseljonas / java-libpst

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

.pst with one file with attachment convert issue #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run pst2gmail utility.
2. Connect to Gmail mailbox
3. Choose "Top of Outlook data file" folder from attached .pst file for 
converting to any Gmail folders. This folder contains one email with one 
attachment.

What is the expected output? What do you see instead?
I expect transfer, but getting following error:

C:\...st\java\0.3.1\pst2gmail.0.1\dist>java -jar PST2Gmail.jar
java.lang.NullPointerException
        at pst2Gmail.Transfer.run(Transfer.java:296)
        at java.lang.Thread.run(Unknown Source)
Error transferring folder: Top of Outlook data file

java.lang.StringIndexOutOfBoundsException: String index out of range: -4
        at java.lang.String.substring(Unknown Source)
        at java.lang.String.substring(Unknown Source)
        at pst2Gmail.Transfer.convertMessage(Transfer.java:508)
        at pst2Gmail.Transfer.transferFolder(Transfer.java:446)
        at pst2Gmail.Transfer.run(Transfer.java:342)
        at java.lang.Thread.run(Unknown Source)

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

pst2gmail.0.1.zip, Windows XP

Please provide any additional information below.

Great library! Thanks for your work. Please help us to fix this issue.

Regards,
Maxim

Original issue reported on code.google.com by justpdat...@gmail.com on 13 Jul 2010 at 12:41

Attachments:

GoogleCodeExporter commented 9 years ago
okay, I've addressed this in SVN for the library, but not rolled it out to 
pst2gmail as it will take a little more work.

Basically, instead of the attached email being a real attachment, it is an 
embedded one.  Previously it was thought that only calendar items were attached 
this way, but it makes sense that other outlook objects would follow the same 
pattern.

I've changed the API some to accommodate this, you can use code like the 
following to get at your attached email:

PSTFile pstFile = new PSTFile("test.pst");
PSTMessage message = (PSTMessage)PSTObject.detectAndLoadPSTObject(pstFile, 
2097188); //2097188 being the id of your message
PSTAttachment attachment = message.getAttachment(0);
if (attachment.getAttachMethod() == PSTAttachment.ATTACHMENT_METHOD_EMBEDDED) {
    PSTMessage attachedMessage = attachment.getEmbeddedPSTMessage();
    System.out.println(attachedMessage.getBody());
}

Original comment by rjohnson...@gmail.com on 23 Jul 2010 at 10:54

GoogleCodeExporter commented 9 years ago
Thanks for the fix!

Could you help me how to find "descriptorIndex" value for each object (i.e: 
PSTObject, PSTMessage, PSTTask, PSTFoder) ?

For the code above:

(PSTMessage)PSTObject.detectAndLoadPSTObject(pstFile, 2097188); //2097188 being 
the id of your message.

As I understand, I could get DescriptorIndexNode value for each item and use 
following method:

static PSTObject detectAndLoadPSTObject(PSTFile theFile, DescriptorIndexNode 
folderIndexNode)

But it's big value to store in DB (32 bytes mean 64 chars in hex). A long value 
is preferable.

Regards,
Maxim

Original comment by justpdat...@gmail.com on 26 Jul 2010 at 1:29

GoogleCodeExporter commented 9 years ago
just off the top of my head as don't have time to check it properly atm, you 
should be able to do:

long PSTObject.getDescriptorNode().descriptorIdentifier

PSTObject.detectAndLoadPSTObject can also take a long as an argument.

Note that these are really internal indexes used by the PST and probably 
wouldn't be that useful for anything else.  I don't even know if they are 
guaranteed to stay the same over time! :/ Probably something in the MS docs 
about that.

Original comment by rjohnson...@gmail.com on 26 Jul 2010 at 1:47