Extracting Information from MSG files

Preparation

Download and install python from https://www.python.org/downloads

open command prompt and run:

pip install https://github.com/mattgwwalker/msg-extractor/zipball/master

Extract data from MSG file

This will install msg-extractor python library for working with MSG files

The python script ExtractMsg.py automates the extraction of key email data (from, to, cc, date, subject, body) and the email’s attachments.

https://github.com/mattgwwalker/msg-extractor/

Running python scripts from package

Is done by using “Script” Package Action:

Script Package Action

Set File Name

Script to extract data from MSG file

Python script

import ExtractMsg,os,etltools

msg = ExtractMsg.Message(etltools.GetVariable('#FileName#'))
etltools.SetVariable('#MessageSender#',msg.sender)
etltools.SetVariable('#MessageSentDate#',msg.date)
etltools.SetVariable('#MessageSubject#',msg.subject)
etltools.SetVariable('#MessageBody#',msg.body)

oldDir = os.getcwd()

os.chdir(etltools.GetVariable('#DirectoryName#'))

for attachment in msg.attachments:
attachment.save()

os.chdir(oldDir)

Result.Value = 1

For more technologies supported by our ETL Software see Advanced ETL Processor Versions

Confused? Ask question on our ETL Forum

Posted on January 15, 2025 • 1 min read • 129 words
www.etl-tools.com About Support Pricing Cookies Policy Term Of Use Privacy Policy License