You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First thanks a lot for this awesome module ! Neat job !
Bug Metadata
Using latest supported version of extract_msg
Your python version: Python [2.7]
How did you launch extract_msg?
I used the extract_msg package
Describe the bug
When saving attachments, there is a special treatment for nested msg which are extracted by default, and attachement and mail content are put in a specific folder.
I need a way to specify an option to save function so I can consider msg attachment as normal attachment and save them as is in the specified folder.
Is it possible ? I can code it and submit a PR if you want !
[ If applicable ]
**What code did you use or can we use to reproduce this error?
import extract_msg
mail = extract_msg.Message("mail.msg")
attachments[0].save(customPath="/tmp/tmp42/")
Is there a message.msg file you want to share to help us reproduce this?
any msg with a nested msg file as attachment
Traceback
no traceback it's working, I only need a new "feature"
Screenshots
N/A
Additional context
You module is used in FAME (https://github.com/certsocietegenerale/fame) I'd like to extract the attachement as "raw" file chain the different analysis even if it's a nested msg.
Activity
TheElementalOfDestruction commented on Mar 31, 2020
@TheElementalOfDestruction I was wondering if this was still the case. It looks like it from what I can see when I do a .save() on a msg attachment. But since it has been a year I wanted to check if any changes had been made that would allow this?
TheElementalOfDestruction commented on Nov 20, 2022
No, this is still impossible. However I've started looking into writing a new class that should hopefully be able to help, but it requires that it can write the file type from the ground up and taking an annoying amount of work.
If someone also were to write code that could be used to write a new file (the format is in [MS-CFB]) then I could work to implement it, otherwise I have to write it myself.
TheElementalOfDestruction commented on Nov 24, 2022
Okay, so the branch ole-writer is where i have been making progress on the update that will allow you to finally save embedded MSG files. It... well, it works according to 7-zip and the olefile module that we use, with all of the files being successfully copied from the original file to a new file (that was the current test). olefile can read all of the streams, msg-extractor can open, read, and save it with no apparent issues, 7-zip can read it, reports no issues, and can extract all files without reporting an issue.
Outlook is where I am stuck, because it just gives a very generic "Cannot read the item." Not only that, but it actually modifies the file copying parts around and changing the file system to the point where olefile stops liking it nearly a much (because the file.directory entries are largely duplicated). I'm reading through as much documentation as I can and am now about to try using it to make a different file type to see if that is openable by it's respective program just to test that nothing seems wrong with the main file structure.
If anyone would like to try and look at the output and documentation to see if I'm just overlooking something, let me know if you find any issues.
This feature has finally been added, and I'm really excited about it. The code was one of the more annoying things I've had to implement due to many annoyances I've have with the documentation and a large number of small mistakes or oversights I made during it's development. It took a solid 11 days of work to make it happen as most of the code I had to write from the ground up. I'm just glad I found a module to make it so I didn't have to write my own red-black tree.
In version 0.38.0 you can now save embedded MSG files using MSGFile.export with the relevant instance, can switch the behavior of MessageBase.save and Attachment.save to save attached MSG files as .msg files instead of calling their save functions using the extractEmbedded argument, and even use this behavior from the command line with the --extract-embedded option.
I'll work on updating the wiki soon to reflect this new feature.
Activity
TheElementalOfDestruction commentedon Mar 31, 2020
This is not something that we can implement given the current status of creating an OleFile storage using the OleFile module.
[-]Impossible to save an nested msg as msg ? [/-][+]Impossible to save an nested msg as msg? [/+]hub-il commentedon Nov 20, 2022
@TheElementalOfDestruction I was wondering if this was still the case. It looks like it from what I can see when I do a .save() on a msg attachment. But since it has been a year I wanted to check if any changes had been made that would allow this?
TheElementalOfDestruction commentedon Nov 20, 2022
No, this is still impossible. However I've started looking into writing a new class that should hopefully be able to help, but it requires that it can write the file type from the ground up and taking an annoying amount of work.
If someone also were to write code that could be used to write a new file (the format is in [MS-CFB]) then I could work to implement it, otherwise I have to write it myself.
TheElementalOfDestruction commentedon Nov 24, 2022
Okay, so the branch
ole-writeris where i have been making progress on the update that will allow you to finally save embedded MSG files. It... well, it works according to 7-zip and theolefilemodule that we use, with all of the files being successfully copied from the original file to a new file (that was the current test).olefilecan read all of the streams,msg-extractorcan open, read, and save it with no apparent issues, 7-zip can read it, reports no issues, and can extract all files without reporting an issue.Outlook is where I am stuck, because it just gives a very generic "Cannot read the item." Not only that, but it actually modifies the file copying parts around and changing the file system to the point where
olefilestops liking it nearly a much (because the file.directory entries are largely duplicated). I'm reading through as much documentation as I can and am now about to try using it to make a different file type to see if that is openable by it's respective program just to test that nothing seems wrong with the main file structure.If anyone would like to try and look at the output and documentation to see if I'm just overlooking something, let me know if you find any issues.
TheElementalOfDestruction commentedon Nov 30, 2022
This feature has finally been added, and I'm really excited about it. The code was one of the more annoying things I've had to implement due to many annoyances I've have with the documentation and a large number of small mistakes or oversights I made during it's development. It took a solid 11 days of work to make it happen as most of the code I had to write from the ground up. I'm just glad I found a module to make it so I didn't have to write my own red-black tree.
In version 0.38.0 you can now save embedded MSG files using
MSGFile.exportwith the relevant instance, can switch the behavior ofMessageBase.saveandAttachment.saveto save attached MSG files as .msg files instead of calling their save functions using theextractEmbeddedargument, and even use this behavior from the command line with the--extract-embeddedoption.I'll work on updating the wiki soon to reflect this new feature.