Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storing .msg attachments to server #17

Open
GTCrais opened this issue Aug 21, 2020 · 1 comment
Open

Storing .msg attachments to server #17

GTCrais opened this issue Aug 21, 2020 · 1 comment

Comments

@GTCrais
Copy link

GTCrais commented Aug 21, 2020

I have a somewhat specific issue - the .msg email files I'm parsing sometimes have other .msg files as attachments. As I iterate over the attachments, calling ->copyToStream(...) on the .msg attachments fails (as opposed to calling the same method on, for example, a .pdf attachment, which works normally). Calling ->getData() on the .msg attachment returns a \Hfig\MAPI\Message\Message object. How do I save this .msg attachment (or the underlying Message object) as a physical .msg file on the server?

@hfig
Copy link
Owner

hfig commented Aug 23, 2020

So, from memory, a MAPI attachment isn't stored as an attachment, it's stored as another sub-document in the OLE compound document. Other types of OLE compound documents - .DOC, .XLS etc - can theoretically also be stored this way.

This library doesn't implement writing of an OLE compound document. You have a couple of options -

  1. You can convert it to RFC822 Mime and save it as an .eml file
  2. You can implement the code to write the file.

On the second option:

  • The PEAR::OLE library supports writing (have a look at the https://github.com/pear/OLE/blob/master/OLE/PPS/Root.php ), though I can't vouch for its quality.
  • The Message class is provided with an OLE root element in the $obj member. Unfortunately, the $obj member is protected, so your implementation will require a fork.

Get it working and I'm happy to merge a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants