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

Attachments error if type property is missing on embedded msg files #318

Closed
dpjk opened this issue Dec 22, 2022 · 6 comments
Closed

Attachments error if type property is missing on embedded msg files #318

dpjk opened this issue Dec 22, 2022 · 6 comments

Comments

@dpjk
Copy link

dpjk commented Dec 22, 2022

Currently, if a .msg file which has an .eml or .msg file as an attachment is opened using extract_msg.openMsg(), it will error out when it tries to get the .eml or .msg file attachment with the following:

../docs/email_document/email_document_mod.py:95: in convert
    self.extract_msg_docs()
../docs/email_document/email_document_mod.py:31: in extract_msg_docs
    msg = extract_msg.openMsg(self.body)
../../venv/lib/python3.8/site-packages/extract_msg/utils.py:620: in openMsg
    return Message(path, **kwargs)
../../venv/lib/python3.8/site-packages/extract_msg/message_base.py:86: in __init__
    super().__init__(path, **kwargs)
../../venv/lib/python3.8/site-packages/extract_msg/msg.py:154: in __init__
    self.attachments
../../venv/lib/python3.8/site-packages/extract_msg/msg.py:582: in attachments
    self._attachments.append(self.attachmentClass(self, attachmentDir))
../../venv/lib/python3.8/site-packages/extract_msg/attachment.py:49: in __init__
    elif (self.props['37050003'].value & 0x7) == 0x7:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = {}, key = '37050003'

    def __getitem__(self, key):
>       return self.__props.__getitem__(key)
E       KeyError: '37050003'

../../venv/lib/python3.8/site-packages/extract_msg/properties.py:70: KeyError

Would it be possible to update the attachment gathering so that the .eml or .msg file attachments are successfully retrieved?

@dpjk dpjk changed the title Support for an msg email that contains another msg or eml file as an attachment Support for a msg email that contains another msg or eml file as an attachment Dec 22, 2022
@TheElementalOfDestruction
Copy link
Collaborator

This is not related to a lack of support for embedded emails, this is due to your file missing a property that is expected to always exist on every attachment. Usually it's only checked under very specific circumstances. I need to check if the property is considered mandatory or has a listing for what to do if it's missing.

The line where it is erroring is the code trying to figure out the actual type of structure that the attachment uses, and it failing to confirm it.

@TheElementalOfDestruction TheElementalOfDestruction changed the title Support for a msg email that contains another msg or eml file as an attachment Attachments error if type property is missing on embedded msg files Dec 22, 2022
@TheElementalOfDestruction
Copy link
Collaborator

After checking the documentation, the wording leads me to believe that the property is considered to be mandatory. It also does not specify any kind of handling for when it is missing, so I'm at a bit of a loss in where to go except to add a clarification to the error. Trying to do otherwise has the problem of being rather complicated to achieve.

Out of curiosity, were those msg files generated by outlook or some other program? If they were generated by outlook, does outlook appear to handle them properly with the ability to open the embedded files?

@dpjk
Copy link
Author

dpjk commented Dec 23, 2022

Not certain how the .msg file was generated. The .msg file does open in outlook (using office 365 online) and appears to be fine. After opening the .msg, it does have an email as an attachment that can also be opened successfully within outlook. Thank you for the info!

@TheElementalOfDestruction
Copy link
Collaborator

Based on that, I think I can add some implementation that might try to figure it out based on that information. I'll let you know.

@TheElementalOfDestruction
Copy link
Collaborator

Okay, I just pushed some code to the next-release branch. Can you install from that and let me know if that fixes the issue for those msg files?

@TheElementalOfDestruction
Copy link
Collaborator

This should now be fixed in version 0.39.0

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