Reputation: 4094
I am using python 3.6 and the email module to extract the content of some .eml files (Lotus Notes Email Files).
Below is my code:
def parseEmail(emailFile):
#emailFile is the path of the .eml file
with open(emailFile, 'rb') as fp:
policy500 = policy.default.clone(max_line_length=500)
msg = BytesParser(policy=policy500).parse(fp)
text = msg.get_body(preferencelist=('plain')).get_content()
...
However, for some eml files (not all!), the code wlil give error when executing the line msg.get_body().get_content()
which gives 'NoneType' object has no attribute 'get_content'
Why is this happening and how to resolve it? Any suggestion is appreciated!
Upvotes: 2
Views: 2430
Reputation: 51
I also have faced the same issue while reading the email data from .eml file. I have solved this issue by re-downloading the .eml file from Outlook web application.
The first .eml file by which I was facing issue was downloaded from default application I got in my computer (MAIL).
Upvotes: 1