Skip to main content

Client for Microsoft Exchange Web Services (EWS)

Project description

This module provides an well-performing interface for communicating with a Microsoft Exchange 2007-2016 Server or Office365 using Exchange Web Services (EWS). It currently only implements autodiscover and functions for manipulating calendar and mailbox items.

Usage

Here is a simple example that inserts, retrieves and deletes calendar items in an Exchange calendar:

from exchangelib import DELEGATE
from exchangelib.account import Account
from exchangelib.configuration import Configuration
from exchangelib.ewsdatetime import EWSDateTime, EWSTimeZone
from exchangelib.folders import CalendarItem
from exchangelib.services import IdOnly

year, month, day = 2016, 3, 20
tz = EWSTimeZone.timezone('Europe/Copenhagen')

# Build a list of calendar items
calendar_items = []
for hour in range(7, 17):
    calendar_items.append(CalendarItem(
        start=tz.localize(EWSDateTime(year, month, day, hour, 30)),
        end=tz.localize(EWSDateTime(year, month, day, hour+1, 15)),
        subject='Test item',
        body='Hello from Python',
        location='devnull',
        categories=['foo', 'bar'],
    ))

config = Configuration(username='MYWINDOMAIN\myusername', password='topsecret')
account = Account(primary_smtp_address='john@example.com', config=config, autodiscover=True, access_type=DELEGATE)

# Create the calendar items in the user's calendar
res = account.calendar.add_items(calendar_items)
print(res)

# Get Exchange ID and changekey of the calendar items we just created
ids = account.calendar.find_items(
    start=tz.localize(EWSDateTime(year, month, day)),
    end=tz.localize(EWSDateTime(year, month, day+1)),
    categories=['foo', 'bar'],
    shape=IdOnly,
)
print(ids)

# Get the rest of the attributes on the calendar items we just created
items = account.calendar.get_items(ids)
print(items)

# Delete the calendar items again
res = account.calendar.delete_items(ids)
print(res)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exchangelib-1.3.7.tar.gz (45.2 kB view details)

Uploaded Source

File details

Details for the file exchangelib-1.3.7.tar.gz.

File metadata

  • Download URL: exchangelib-1.3.7.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for exchangelib-1.3.7.tar.gz
Algorithm Hash digest
SHA256 cfda3077e148ef18d02b72ac03a438f821eeb50d0695e48e6e5fbb4d72b45195
MD5 791aee441cd2d250087c8b393d359c90
BLAKE2b-256 94c74ad9922a542b19a5edd1fccc809fea18c63783c10a9a07c84c93e0361b97

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page