Skip to content

Create a recurring event (weekly, 4 occurrences).

Shows how to set a recurrence pattern on an event.

Permissions

Requires delegated permission Calendars.ReadWrite.

Reference

View source

from datetime import datetime, timedelta

from office365.graph_client import GraphClient
from office365.outlook.mail.recurrencepatterntype import RecurrencePatternType
from office365.outlook.mail.recurrencerangetype import RecurrenceRangeType
from tests.settings import client_id, password, tenant, username

client = GraphClient(tenant=tenant).with_username_and_password(client_id, username, password)

when = datetime.utcnow() + timedelta(days=1)

event = client.me.calendar.events.add(
    subject="Weekly Standup",
    body="Team sync meeting.",
    start=when,
    end=when + timedelta(hours=1),
).execute_query()

event.set_recurrence(
    pattern_type=RecurrencePatternType.weekly,
    days_of_week=["monday", "wednesday", "friday"],
    interval=1,
    range_type=RecurrenceRangeType.numbered,
    occurrences=4,
    start_date=when.date(),
).update().execute_query()

print(f"Recurring event created: {event.subject}  (ID: {event.id})")

← Back to Events