A python utility to convert an Outlook for Mac archive (.olm file), that can only be opened with Outlook for Mac, to a set of standard .eml files that can be opened by almost all email clients.
Output EML messages are organised hierarchically, for example a message contained in an OLM file will be output to an EML file like "<output directory>/example@example.com/Inbox/Subject - Mon, 04 July 2022 21.04.56.eml"
.
Can be used as a command line interface or as a module.
Supports attachments but can only output emails with the HTML and plain text content types.
Command line:
python3 olmConvert.py <path to OLM file> <output directory> [--noAttachments]
--noAttachments
- No attachments are included in generated EML files (including embedded images), reducing file size of generated EML files.
Convert OLM file specified by olmPath
, creating a directory of EML files at outputDir
. Will not include attachments if optional parameter noAttachments
is set to True.
Reads OLM format XML message (xmlString
) and returns a ConvertedMessage object containing the message converted to a EML format string. Can also return ValueError.
olmZip
parameter is a instance of zipfile.ZipFile
open on the OLM file. This parameter is required in order to convert attachments.
If noAttachments
parameter is True, no attachments will be included in generated EML messages.
Converts email header string value to RFC2047 base64 encoded UTF-8 string (https://datatracker.ietf.org/doc/html/rfc2047).
Converts <emailAddress>
element (xml.etree.ElementTree.Element) to an email header value.
Generates a MIME boundary ID (https://datatracker.ietf.org/doc/html/rfc2046#section-5.1.1).
Wraps lines of a given HTML body to maximum of 78 characters as recommended by RFC 2822 (https://datatracker.ietf.org/doc/html/rfc2822#section-2.1.1).
Generates EML section (without MIME boundaries) specifying attachments.
attachmentElm
specifies the <messageAttachment>
OLM element (xml.etree.ElementTree.Element) containing the attachment.
olmZip
parameter is a instance of zipfile.ZipFile
open on the OLM file. Required as attachment files are contained within OLM file.