mtryingtocode
mtryingtocode

Reputation: 969

Python 3.6 Extract text from .msg files

I'm currently using the module textract (making use of msg-extractor) to get all text content from msg files. But I get some encoding errors for some files which seem to be related to the open issues for textract (based on the link)

Are there other modules I can use to extract text from msg files? I'm using Python 3.6 for my development

Upvotes: 0

Views: 1939

Answers (1)

Amey P Naik
Amey P Naik

Reputation: 718

You can use extract_msg module for extracting the metadata from the .MSG files as well as the body.

import extract_msg
with extract_msg.Message(filepath) as msg:
     msg_body = msg.body
     msg_subject = msg.subject
     print(msg_body)

Upvotes: 1

Related Questions