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)
- 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:
- forward()[source]
Creates a new message that is a forward this message
- Returns:
new message
- Return type:
- 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
- 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:
- 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
List of internetMessageHeaders, see definition: https://learn.microsoft.com/en-us/graph/api/resources/internetmessageheader?view=graph-rest-1.0
- 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
- web_link
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
- 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
- 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
- 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