Skip to main content

Simple inbox event listener for exchangelib.

Project description

Inbox event listener for exchangelib

This library listens for events in the inbox and raises an event.

Usage

Create listener:

from exchangelib import DELEGATE, Account, Credentials, Configuration
from exchangelib.properties import NewMailEvent, MovedEvent
from exchangelib_listener import Listener

creds = Credentials(
    username='EMAIL_ADDRESS',
    password='PASSWORD'
)
config = Configuration(
    server='SERVER',
    credentials=creds
)
acct = Account(
    primary_smtp_address='EMAIL_ADDRESS',
    config=config,
    access_type=DELEGATE
)

listener = Listener(acct)

Create a method to call when events are raised:

def events_received(events):
    for event in events:
        if isinstance(event, NewMailEvent):
            # Do something
        elif isinstance(event, MovedEvent):
            # Do something

listener.streaming_events_received += events_received
listener.listen()

Or receive a single event:

def new_messaged_received():
    # Do something

listener.streaming_event_received += new_messaged_received
listener.listen(NewMailEvent)

Project details


Download files

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

Source Distribution

exchangelib_listener-1.1.1.tar.gz (2.4 kB view hashes)

Uploaded Source

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