You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Ezequiel Foncubierta <ef...@zaizi.com> on 2011/06/13 15:43:03 UTC

How to extract embedded documents from a .msg

Hi,

I'm using the MAPIMessage class to extract attachments from an email message and have some troubles to extract embedded documents (E.g. a message attached). I'm trying to go through DirectoryChunk, but I don't find a way to extract them. Basically, I need to access to its filename, raw data (InputStream?) and mimetype. Is it possible? How can I get them?

Thanks. Regards,
This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.

Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to extract embedded documents from a .msg

Posted by Nick Burch <ni...@alfresco.com>.
On Mon, 13 Jun 2011, Ezequiel Foncubierta wrote:
> There is another case, when the message has an embedded 
> image/video/whatever you got the same, therefore you shouldn't use 
> getAsEmbededMessage to get the embedded document.

I've not seen that. Any chance you could open a new bug in bugzilla, and 
upload a sample file that shows this? (We can then use this as a basis for 
enhancing DirectoryChunk, and unit testing it)

> On the other hand, is it possible to get the raw data from a MAPIMessage 
> object?

>From a DirectoryChunk you can get the underlying POIFS DirectoryNode with 
a call to getDirectory(). From their, loop over all the directory entries 
looking for something you find interesting. When you have something that 
catches your eye, DocumentInputStream will let you read it.

See http://poi.apache.org/poifs/how-to.html for information on working at 
the POIFS level

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to extract embedded documents from a .msg

Posted by Ezequiel Foncubierta <ef...@zaizi.com>.
There is another case, when the message has an embedded image/video/whatever you got the same, therefore you shouldn't use getAsEmbededMessage to get the embedded document.

On the other hand, is it possible to get the raw data from a MAPIMessage object?

On 13 Jun 2011, at 15:46, Nick Burch wrote:

> On Mon, 13 Jun 2011, Ezequiel Foncubierta wrote:
>> Problem is that embedded attachments (e.g. when you attach a .msg file) have null values in attachData, attachExtension, attachFileName and so on. Only attachmentDirectory (of type DirectoryChunk) has a value. I think need to extract the attachment from a DirectoryChunk object, and I don't know if there is a way to do it.
> 
> Hmm. The only files I've ever seen with a DirectoryChunk but no attachData were where there was another MAPI Message embedded inside the first
> 
> Assuming that's what you have, just call getAsEmbededMessage() on the directory to get your message
> 
> Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 



This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.

Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to extract embedded documents from a .msg

Posted by Nick Burch <ni...@alfresco.com>.
On Mon, 13 Jun 2011, Ezequiel Foncubierta wrote:
> Problem is that embedded attachments (e.g. when you attach a .msg file) 
> have null values in attachData, attachExtension, attachFileName and so 
> on. Only attachmentDirectory (of type DirectoryChunk) has a value. I 
> think need to extract the attachment from a DirectoryChunk object, and I 
> don't know if there is a way to do it.

Hmm. The only files I've ever seen with a DirectoryChunk but no attachData 
were where there was another MAPI Message embedded inside the first

Assuming that's what you have, just call getAsEmbededMessage() on the 
directory to get your message

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to extract embedded documents from a .msg

Posted by Ezequiel Foncubierta <ef...@zaizi.com>.
Thanks Nick. I'm using version 3.8 beta3.

Problem is that embedded attachments (e.g. when you attach a .msg file) have null values in attachData, attachExtension, attachFileName and so on. Only attachmentDirectory (of type DirectoryChunk) has a value. I think need to extract the attachment from a DirectoryChunk object, and I don't know if there is a way to do it.

On 13 Jun 2011, at 15:06, Nick Burch wrote:

> On Mon, 13 Jun 2011, Ezequiel Foncubierta wrote:
>> I'm using the MAPIMessage class to extract attachments from an email message and have some troubles to extract embedded documents (E.g. a message attached). I'm trying to go through DirectoryChunk, but I don't find a way to extract them. Basically, I need to access to its filename, raw data (InputStream?) and mimetype. Is it possible? How can I get them?
> 
> First up, make sure you're using 3.8 beta 3 as there has been some work done on the code recently
> 
> On a MAPIMessage, call getAttachmentFiles() to get AttachmentChunks. On each attachment, use attachFileName / attachLongFileName to figure out if it's one you want. If it is, your data is in attachData
> 
> Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 



This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.

Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to extract embedded documents from a .msg

Posted by Nick Burch <ni...@alfresco.com>.
On Mon, 13 Jun 2011, Ezequiel Foncubierta wrote:
> I'm using the MAPIMessage class to extract attachments from an email 
> message and have some troubles to extract embedded documents (E.g. a 
> message attached). I'm trying to go through DirectoryChunk, but I don't 
> find a way to extract them. Basically, I need to access to its filename, 
> raw data (InputStream?) and mimetype. Is it possible? How can I get 
> them?

First up, make sure you're using 3.8 beta 3 as there has been some work 
done on the code recently

On a MAPIMessage, call getAttachmentFiles() to get AttachmentChunks. On 
each attachment, use attachFileName / attachLongFileName to figure out if 
it's one you want. If it is, your data is in attachData

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org