🔍 Code Extractor

class EventMessage

Maturity: 51

A class representing an event message in Outlook, which can be a meeting request, cancellation, or response (acceptance, tentative acceptance, or decline).

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/messages/event_message.py
Lines:
6 - 24
Complexity:
moderate

Purpose

EventMessage extends the Message class to provide specialized functionality for handling calendar event-related messages in Microsoft Outlook. It provides access to the associated calendar event and recurrence pattern information. This class is used when working with meeting invitations, responses, and cancellations through the Microsoft Graph API or Office 365 REST API.

Source Code

class EventMessage(Message):
    """A message that represents a meeting request, cancellation, or response (which can be one of the following:
    acceptance, tentative acceptance, or decline)."""

    @property
    def event(self):
        """The event associated with the event message. The assumption for attendees or room resources is that
        the Calendar Attendant is set to automatically update the calendar with an event when meeting request event
        messages arrive. Navigation property. Read-only."""
        from office365.outlook.calendar.events.event import Event

        return self.properties.get(
            "event", Event(self.context, ResourcePath("event", self.resource_path))
        )

    @property
    def patterned_recurrence(self):
        """"""
        return self.properties.get("patternedRecurrence", PatternedRecurrence())

Parameters

Name Type Default Kind
bases Message -

Parameter Details

context: The client context object used for API communication with Office 365 services. Inherited from parent Message class.

resource_path: The resource path identifying this event message in the Office 365 API hierarchy. Inherited from parent Message class.

Return Value

Instantiation returns an EventMessage object that represents a meeting-related message. The class provides properties that return Event objects (for the associated calendar event) and PatternedRecurrence objects (for recurring meeting patterns).

Class Interface

Methods

@property event(self) -> Event property

Purpose: Returns the calendar event associated with this event message. This is the actual meeting/event that the message refers to.

Returns: An Event object representing the calendar event. If not previously loaded, creates a new Event instance with the appropriate resource path. This is a navigation property that is read-only.

@property patterned_recurrence(self) -> PatternedRecurrence property

Purpose: Returns the recurrence pattern for recurring meetings. Provides information about how and when the meeting repeats.

Returns: A PatternedRecurrence object containing the recurrence pattern details, or None if the event is not recurring.

Attributes

Name Type Description Scope
context ClientContext The client context used for API communication, inherited from parent Message class instance
resource_path ResourcePath The resource path identifying this event message in the API hierarchy, inherited from parent Message class instance
properties dict Dictionary storing the properties of the event message, inherited from parent class. Used internally to cache property values. instance

Dependencies

  • office365
  • office365.outlook.mail.messages.message
  • office365.outlook.mail.patterned_recurrence
  • office365.runtime.paths.resource_path
  • office365.outlook.calendar.events.event

Required Imports

from office365.outlook.mail.messages.event_message import EventMessage
from office365.outlook.mail.messages.message import Message
from office365.outlook.mail.patterned_recurrence import PatternedRecurrence
from office365.runtime.paths.resource_path import ResourcePath

Conditional/Optional Imports

These imports are only needed under specific conditions:

from office365.outlook.calendar.events.event import Event

Condition: only when accessing the 'event' property to avoid circular import issues

Required (conditional)

Usage Example

from office365.graph_client import GraphClient
from office365.outlook.mail.messages.event_message import EventMessage

# Authenticate and create client
client = GraphClient.with_username_and_password(tenant_name, client_id, username, password)

# Get event messages from inbox
event_messages = client.me.messages.filter("@odata.type eq 'microsoft.graph.eventMessage'").get().execute_query()

for msg in event_messages:
    event_msg = EventMessage(msg.context, msg.resource_path)
    
    # Access the associated calendar event
    associated_event = event_msg.event
    print(f"Event subject: {associated_event.subject}")
    
    # Check if it's a recurring meeting
    recurrence = event_msg.patterned_recurrence
    if recurrence:
        print(f"Recurrence pattern: {recurrence.pattern}")

Best Practices

  • EventMessage objects should be created through the Office 365 API client rather than directly instantiated
  • The 'event' property uses lazy loading and creates the Event object on first access
  • The Event import is done inside the property method to avoid circular import issues
  • Always ensure proper authentication context is established before accessing properties
  • The Calendar Attendant should be configured to automatically update calendars when processing event messages
  • Use appropriate filters when querying for event messages to distinguish them from regular messages
  • Properties are read-only and reflect the current state from the Office 365 service
  • The patterned_recurrence property may return None for non-recurring events

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class Event 77.1% similar

    Represents a calendar event in Microsoft 365, providing methods to manage event responses (accept, decline, cancel), reminders, and access to event properties like attendees, attachments, and scheduling details.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/events/event.py
  • class Message 75.0% similar

    Represents an email message in a Microsoft Outlook mailbox folder, providing methods for message operations like sending, replying, forwarding, and managing attachments.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/messages/message.py
  • class CalendarSharingMessage 67.6% similar

    CalendarSharingMessage is a specialized message class that represents calendar sharing messages in Microsoft Outlook, inheriting from the base Message class.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/sharing_message.py
  • class EventCollection 63.9% similar

    A collection class for managing Microsoft Outlook calendar events, providing methods to create and manage events with attendees, time zones, and other properties.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/events/collection.py
  • class MessageCollection 61.8% similar

    A collection class for managing Microsoft Outlook email messages, extending DeltaCollection to provide message-specific operations like creating draft messages.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/messages/collection.py
← Back to Browse