Skip to content

Message

The Message object is the primary interface object in python-oxmsg.

This object is returned by the Message.load() classmethod:

>>> from oxmsg import Message

>>> msg = Message.load("message.msg")
>>> msg.subject
'Agenda for the Acme meeting'

Message

An Outlook email message loaded from an OXMSG format (.msg) file.

load(msg_file: str | IO[bytes] | bytes) -> Message classmethod

Load an instance from msg_file.

msg_file can be a file-path, a file-like object, or the bytes of the MSG file.

attachment_count: int property

Number of attachments on this message.

attachments: tuple[Attachment, ...] property

Attachment object for each attachment in this message.

body: str | None property

The plain-text body of this message; None if not present.

html_body: str | None property

The HTML body of this message if present, None otherwise.

message_headers: dict[str, str] property

From, To, Content-Type, etc. headers for this message as {name: value} mapping.

message_class: str property

Outlook Message Class identifier like "IPM.Note" for this message.

properties: Properties property

Provides access to the properties of this OXMSG object.

recipients: tuple[Recipient, ...] property

Recipient object for each recipient of this message.

sender: str | None property

Name and email address of the message sender.

Like '"John Doe" john@bigisp.com'.

None if it is not recorded in the message. This may occur when the message is a draft or system-generated or perhaps in other cases.

Note that the value of the From: message header is returned when present (usually I expect) and may contain multiple addresses separated by commas.

sent_date: dt.datetime | None property

When this message was submitted by the sender.

This value will be None if the message has not been sent and possibly in other cases.

subject: str property

Subject line of this message.