Skip to main content

A Python package to interact with both on-premises and Office 365 Exchange Web Services

Project description

Welcome to py-ews's documentation!


    .______   ____    ____       ___________    __    ____   _______.
    |   _  \  \   \  /   /      |   ____\   \  /  \  /   /  /       |
    |  |_)  |  \   \/   / ______|  |__   \   \/    \/   /  |   (----`
    |   ___/    \_    _/ |______|   __|   \            /    \   \    
    |  |          |  |          |  |____   \    /\    / .----)   |   
    | _|          |__|          |_______|   \__/  \__/  |_______/    
                                                                 


    A Python package to interact with Exchange Web Services

py-ews is a cross platform python package to interact with both Exchange 2010 to 2019 on-premises and Exchange Online (Office 365).

This package will wrap all Exchange Web Service endpoints, but currently is focused on providing eDiscovery endpoints.

Features

py-ews has the following notable features in it's current release:

  • Autodiscover support
  • Delegation support
  • Impersonation support
  • OAUth2 support
  • Retrieve all mailboxes that can be searched based on credentials provided
  • Search a list of (or single) mailboxes in your Exchange environment using all supported search attributes
  • Delete email items from mailboxes in your Exchange environment
  • Retrieve mailbox inbox rules for a specific account
  • Find additional hidden inbox rules for a specified account
  • Plus more supported endpoints

Currently this package supports the following endpoint's:

Installation

OS X & Linux:

pip install py-ews

Windows:

pip install py-ews

Creating EWS Object

For convience, py-ews offers a simple interface to access all available EWS endpoints in the form of methods. Each of these methods have their own required inputs based on the individual endpoint. No matter which endpoint you use, you must first instantiate the EWS class by providing authentication details.

When instantiating the EWS class you will need to provide credentials which will be used for all methods within the EWS class.

from pyews import EWS

ews = EWS(
      'myaccount@company.com',
      'Password1234'
)

If you would like to use an alternative EWS URL then provide one using the ews_url parameter when instantiating the EWS class.

from pyews import EWS

ews = EWS(
      'myaccount@company.com',
      'Password1234',
      ews_url='https://outlook.office365.com/autodiscover/autodiscover.svc'
)

If you would like to specify a specific version of Exchange to use, you can provide that using the exchange_version parameter. By default pyews will attempt all Exchange versions as well as multiple static and generated EWS URLs.

Finally, if you would like to impersonate_as a specific user you must provide their primary SMTP address when instantiating the EWS class object:

from pyews import EWS

ews = EWS(
      'myaccount@company.com',
      'Password1234',
      impersonate_as='myotheraccount@company.com'
)

Exchange Search Multi-Threading

You can also specify multi_threading=True and when you search mailboxes we will use multi-threading to perform the search.

Using Provided Methods

Once you have instantiated the EWS class with your credentials, you will have access to pre-exposed methods for each endpoint. These methods are:

  • get_service_configuration
  • get_searchable_mailboxes
  • get_user_settings
  • resolve_names
  • execute_ews_search
  • execute_outlook_search
  • get_inbox_rules
  • get_hidden_inbox_rules
  • get_item
  • get_attachment
  • sync_folder_hierarchy
  • sync_folder_items
  • create_item
  • delete_item
  • search_and_delete_message
  • get_domain_settings
  • find_items
  • search_mailboxes_using_find_item
  • create_search_folder
  • find_search_folder
  • delete_search_folder

Access Classes Directly

In some cases you may want to skip using the EWS interface class and build your own wrapper around py-ews. To do this, you must first import the Authentication class and provide credential and other details before invoking a desired endpoint. Below is an example of this:

from pyews import Authentication, GetSearchableMailboxes

Authentication(
      'myaccount@company.com',
      'Password1234'
)

reference_id_list = []
for mailbox in GetSearchableMailboxes().run():
      reference_id_list.append(mailbox.get('reference_id'))
      print(mailbox)

As you can see, you must instantiate the Authentication class first before calling an endpoint. By the way, you can import all endpoints directly without using the EWS interface.

For more examples and usage, please refer to the individual class documentation

Release History

  • 1.0.0
    • Initial release of py-ews and it is still considered a work in progress
  • 2.0.0
    • Revamped logic and overhauled all endpoints and classes
  • 3.0.0
    • Refactored completely - this can be considered a new version

Meta

Josh Rickard – @MSAdministrator

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/swimlane/pyews/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

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

py-ews-3.2.0.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

py_ews-3.2.0-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file py-ews-3.2.0.tar.gz.

File metadata

  • Download URL: py-ews-3.2.0.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for py-ews-3.2.0.tar.gz
Algorithm Hash digest
SHA256 f088fae2499040a25c6a61321315a407c46e81c2b8522184c214b23c63a00bde
MD5 d22fe8c23ce1439e257bfb8e39c9309a
BLAKE2b-256 4a024e323d5b6d64280d095fd33b2a52b84482446bababb9eafaaf89265bc065

See more details on using hashes here.

File details

Details for the file py_ews-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: py_ews-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for py_ews-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aedb958a5fbbe474e195d11b57e70bfbbbe779ce2bcf9cc449527cc21e385c4d
MD5 cb86eacc2517d9e165147f524bf90e68
BLAKE2b-256 bed80ce36d19e90c71aa62adeed56cfd574d545b1b430f2ab202470656d47252

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