New submission from Jay Patel <jay.pa...@crestdatasys.com>:

I need to extract the email data from an MSG file on Python v2.7. But as Python 
v2.7 has been deprecated, I tried to replicate this scenario on Python v3.8 and 
faced the same issue.
I am trying to extract the message using the "Message" class of the 
"extract_msg" module. After extracting the text from the "Message" object, I am 
using email.message_from_string() method to separate the headers and the body 
(or payload). The same workflow can be observed in the "extract_mail.py" file.
The issue with the attached file, "msgfile_not_working_correctly.msg", is that 
the headers of this file begin with "Microsoft Mail Internet Headers Version 
2.0" which is interpreted as body and not as headers (as it is not in the 
standard email headers format like "To": "recei...@gmail.com").
According to this 
(https://support.microsoft.com/en-us/office/view-internet-message-headers-in-outlook-cd039382-dc6e-4264-ac74-c048563d212c)
 link the message headers in Outlook will begin with "Microsoft Mail Internet 
Headers Version 2.0" which is added by Outlook (mentioned in the "Interpreting 
email headers" section of the mentioned link). 
The email data can be observed in the "email_data.txt" file.

I have tried omitting the first line, when there are no headers and it works as 
per the expectation. Can this scenario be handled at the modular level (email 
module) or is there any other way to extract headers for the .msg files.

----------
files: extract_mail.py
messages: 372560
nosy: jpatel
priority: normal
severity: normal
status: open
title: email.message_from_string() is unable to find the headers for the .msg 
files
type: enhancement
versions: Python 3.8
Added file: https://bugs.python.org/file49273/extract_mail.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to