For reading the .msg file, I am using python built in library "email". you can read .msg file by below code.
Thank you guys for your support.
import email def read_MSG(file): email_File = open(file) messagedic = email.Message(email_File) content_type = messagedic["plain/text"] FROM = messagedic["From"] TO = messagedic.getaddr("To") sujet = messagedic["Subject"] email_File.close() return content_type, FROM, TO, sujet myMSG= read_MSG("client.msg") print myMSG
Thank you guys for your support.
Traceback (most recent call last):
ReplyDeleteFile "C:/Python/Programs/msgExtracter/msg_extracter.py", line 11, in
myMSG= read_MSG("TermSheet.msg")
File "C:/Python/Programs/msgExtracter/msg_extracter.py", line 4, in read_MSG
messagedic = email.Message(email_File)
AttributeError: module 'email' has no attribute 'Message'
It looks like the email module has been refactored over time. This fixed the 'LazyImporter' object not callable error for me on Python 2.7.
Deleteunder prior email versions it would have raised the exception
TypeError: 'module' object is not callable
You need to do like
a = email.Message.Message()
or per the new PEP 8 conformant naming
a = email.message.Message()
AttributeError: module 'email' has no attribute 'message'
ReplyDeletelook at above solution in comment section
Delete