Message

class O365.message.Flag(*values)[source]

Bases: CaseEnum

Complete = 'complete'
Flagged = 'flagged'
NotFlagged = 'not_flagged'
class O365.message.MeetingMessageType(*values)[source]

Bases: CaseEnum

MeetingAccepted = 'meeting_accepted'
MeetingCancelled = 'meeting_cancelled'
MeetingDeclined = 'meeting_declined'
MeetingRequest = 'meeting_request'
MeetingTentativelyAccepted = 'meeting_tentatively_accepted'
class O365.message.Message(*, parent=None, con=None, **kwargs)[source]

Bases: ApiComponent, AttachableMixin, HandleRecipientsMixin

Management of the process of sending, receiving, reading, and editing emails.

__init__(*, parent=None, con=None, **kwargs)[source]

Makes a new message wrapper for sending and receiving messages.

Parameters:
  • parent (mailbox.Folder or Account) – parent folder/account to create the message in

  • con (Connection) – connection to use if no parent specified

  • protocol (Protocol) – protocol to use if no parent specified (kwargs)

  • main_resource (str) – use this resource instead of parent resource (kwargs)

  • download_attachments (bool) – whether or not to download attachments (kwargs)

add_category(category)[source]

Adds a category to this message current categories list

add_message_header(name, value)[source]
copy(folder)[source]

Copy the message to a given folder

Parameters:

folder (str or mailbox.Folder) – Folder object or Folder id or Well-known name to copy this message to

Returns:

the copied message

Return type:

Message

delete()[source]

Deletes a stored message

Returns:

Success / Failure

Return type:

bool

forward()[source]

Creates a new message that is a forward this message

Returns:

new message

Return type:

Message

get_body_soup()[source]

Returns the beautifulsoup4 of the html body

Returns:

BeautifulSoup object of body

Return type:

BeautifulSoup

get_body_text()[source]

Parse the body html and returns the body text using bs4

Returns:

body as text

Return type:

str

get_event()[source]

If this is a EventMessage it should return the related Event

get_mime_content()[source]

Returns the MIME contents of this message

mark_as_read()[source]

Marks this message as read in the cloud

Returns:

Success / Failure

Return type:

bool

mark_as_unread()[source]

Marks this message as unread in the cloud

Returns:

Success / Failure

Return type:

bool

move(folder)[source]

Move the message to a given folder

Parameters:

folder (str or mailbox.Folder) – Folder object or Folder id or Well-known name to move this message to

Returns:

Success / Failure

Return type:

bool

reply(to_all=True)[source]

Creates a new message that is a reply to this message

Parameters:

to_all (bool) – whether or not to replies to all the recipients instead to just the sender

Returns:

new message

Return type:

Message

save_as_eml(to_path=None)[source]

Saves this message as and EML to the file system :param Path or str to_path: the path where to store this file

save_draft(target_folder=OutlookWellKnowFolderNames.DRAFTS)[source]

Save this message as a draft on the cloud

Parameters:

target_folder – name of the drafts folder

Returns:

Success / Failure

Return type:

bool

save_message()[source]

Saves changes to a message. If the message is a new or saved draft it will call ‘save_draft’ otherwise this will save only properties of a message that are draft-independent such as:

  • is_read

  • category

  • flag

Returns:

Success / Failure

Return type:

bool

send(save_to_sent_folder=True)[source]

Sends this message

Parameters:

save_to_sent_folder (bool) – whether or not to save it to sent folder

Returns:

Success / Failure

Return type:

bool

to_api_data(restrict_keys=None)[source]

Returns a dict representation of this message prepared to be sent to the cloud

Parameters:

restrict_keys (dict or set) – a set of keys to restrict the returned data to

Returns:

converted to cloud based keys

Return type:

dict

property attachments

List of attachments

property bcc

‘BCC’ list of recipients

property body

Body of the email message

Getter:

Get body text of current message

Setter:

set html body of the message

Type:

str

property body_preview

Returns the body preview

body_type

The body type of the message.

   Type: bodyType

property categories

Categories of this message

Getter:

Current list of categories

Setter:

Set new categories for the message

Type:

list[str] or str

property cc

‘CC’ list of recipients

conversation_id

The ID of the conversation the email belongs to.

   Type: str

conversation_index

Indicates the position of the message within the conversation.

   Type: any

property created

Created time of the message

property flag

The Message Flag instance

folder_id

The unique identifier for the message’s parent mailFolder.

   Type: str

property has_attachments

Check if the message contains attachments

Type:

bool

property importance

Importance of the message

Getter:

Get the current priority of the message

Setter:

Set a different importance level

Type:

str or ImportanceLevel

property inference_classification

Message is focused or not

internet_message_id

The message ID in the format specified by RFC2822.

   Type: str

property is_delivery_receipt_requested

if the delivery receipt is requested for this message

Getter:

Current state of isDeliveryReceiptRequested

Setter:

Set isDeliveryReceiptRequested for the message

Type:

bool

property is_draft

Check if the message is marked as draft

Type:

bool

property is_event_message

Returns if this message is of type EventMessage and therefore can return the related event.

property is_read

Check if the message is read or not

Getter:

Get the status of message read

Setter:

Mark the message as read

Type:

bool

property is_read_receipt_requested

if the read receipt is requested for this message

Getter:

Current state of isReadReceiptRequested

Setter:

Set isReadReceiptRequested for the message

Type:

bool

property meeting_message_type

If this message is a EventMessage, returns the meeting type: meetingRequest, meetingCancelled, meetingAccepted, meetingTentativelyAccepted, meetingDeclined

property message_headers

Custom message headers

Type:

list[dict[str, str]]

property modified

Message last modified time

object_id

Unique identifier for the message.

   Type: str

property received

Message received time

property reply_to

Reply to address

property sender

Sender of the message

Getter:

Get the current sender

Setter:

Update the from address with new value

Type:

str or Recipient

property sent

Message sent time

property single_value_extended_properties

singleValueExtendedProperties

property subject

Subject of the email message

Getter:

Get the current subject

Setter:

Assign a new subject

Type:

str

property to

‘TO’ list of recipients

property unique_body

The unique body of this message

Requires a select to retrieve it.

Return type:

str

The URL to open the message in Outlook on the web.

   Type: str

class O365.message.MessageAttachment(attachment=None, *, parent=None, **kwargs)[source]

Bases: BaseAttachment

class O365.message.MessageAttachments(parent, attachments=None)[source]

Bases: BaseAttachments

get_mime_content(attachment)[source]

Returns the MIME contents of this attachment

save_as_eml(attachment, to_path=None)[source]

Saves this message as and EML to the file system :param MessageAttachment attachment: the MessageAttachment to store as eml. :param Path or str to_path: the path where to store this file

class O365.message.MessageFlag(parent, flag_data)[source]

Bases: ApiComponent

A flag on a message

__init__(parent, flag_data)[source]

An flag on a message Not available on Outlook Rest Api v2 (only in beta)

Parameters:
  • parent (Message) – parent of this

  • flag_data (dict) – flag data from cloud

delete_flag()[source]

Sets this message as un flagged

set_completed(*, completition_date=None)[source]

Sets this message flag as completed :param completition_date: the datetime this followUp was completed

set_flagged(*, start_date=None, due_date=None)[source]

Sets this message as flagged :param start_date: the start datetime of the followUp :param due_date: the due datetime of the followUp

to_api_data()[source]

Returns this data as a dict to be sent to the server

property completition_date

The completion date of the message flag.

Getter:

get the completion_date

Type:

datetime

property due_date

The due date of the message flag.

Getter:

get the due_date

Type:

datetime

property is_completed

Is the flag completed.

Getter:

get the is_completed status

Type:

bool

property is_flagged

Is item flagged.

Getter:

get the is_flagged status

Type:

bool

property start_date

The start date of the message flag.

Getter:

get the start_date

Type:

datetime

property status
class O365.message.RecipientType(*values)[source]

Bases: Enum

BCC = 'bcc'
CC = 'cc'
TO = 'to'