Skip to content

Impossible to save an nested msg as msg?  #117

Closed

Description

@Heat-Miser

Hello,

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

  1. TheElementalOfDestruction commented on Mar 31, 2020

    @TheElementalOfDestruction
    Collaborator

    This is not something that we can implement given the current status of creating an OleFile storage using the OleFile module.

  2. changed the title [-]Impossible to save an nested msg as msg ? [/-] [+]Impossible to save an nested msg as msg? [/+] on Jun 19, 2020
  3. hub-il commented on Nov 20, 2022

    @hub-il

    @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?

  4. TheElementalOfDestruction commented on Nov 20, 2022

    @TheElementalOfDestruction
    Collaborator

    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.

  5. TheElementalOfDestruction commented on Nov 24, 2022

    @TheElementalOfDestruction
    Collaborator

    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.

  6. added
    In ProgressThis issue or feature request has been confirmed or approved, respectively, and is being worked on.
    Nearly ImplementedThis feature has nearly been implemented and will be available in the next version.
    AcceptedThis feature request has been accepted and will be developed
    on Nov 30, 2022
  7. TheElementalOfDestruction commented on Nov 30, 2022

    @TheElementalOfDestruction
    Collaborator

    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.

  8. added
    CompleteThis feature has been fully implemented.
    and removed
    In ProgressThis issue or feature request has been confirmed or approved, respectively, and is being worked on.
    Nearly ImplementedThis feature has nearly been implemented and will be available in the next version.
    on Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

AcceptedThis feature request has been accepted and will be developedCompleteThis feature has been fully implemented.enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions