exchangelib | Python client for Microsoft Exchange Web Services

 by   ecederstrand Python Version: 5.4.1 License: BSD-2-Clause

kandi X-RAY | exchangelib Summary

kandi X-RAY | exchangelib Summary

exchangelib is a Python library. exchangelib has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install exchangelib' or download it from GitHub, PyPI.

This module is an ORM for your Exchange mailbox, providing Django-style access to all your data. It is a platform-independent, well-performing, well-behaving, well-documented, well-tested and simple interface for communicating with an on-premise Microsoft Exchange 2007-2016 server or Office365 using Exchange Web Services (EWS). Among other things, it implements autodiscover, and functions for searching, creating, updating, deleting, exporting and uploading calendar, mailbox, task, contact and distribution list items.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              exchangelib has a highly active ecosystem.
              It has 1056 star(s) with 235 fork(s). There are 39 watchers for this library.
              There were 2 major release(s) in the last 12 months.
              There are 9 open issues and 979 have been closed. On average issues are closed in 80 days. There are no pull requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of exchangelib is 5.4.1

            kandi-Quality Quality

              exchangelib has 0 bugs and 0 code smells.

            kandi-Security Security

              exchangelib has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              exchangelib code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              exchangelib is licensed under the BSD-2-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              exchangelib releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              exchangelib saves you 120822 person hours of effort in developing the same functionality from scratch.
              It has 150042 lines of code, 1605 functions and 214 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed exchangelib and discovered the below as its top functions. This is intended to give you an instant insight into exchangelib implemented functionality, and help decide if they suit your requirements.
            • Extract children from a kwarg
            • Check if value is an iterable
            • Convert a lookup table to an expression
            • Gets a collection of documents
            • Wrapper for paging
            • Convert an XML tree to a string
            • Get elements from the response
            • Bulk delete items
            • Consume an item service
            • Bulk create items
            • Returns a list of objects
            • Fetches a list of folders
            • Returns a sync folder hierarchy
            • Create a saved item
            • Generate the payload for a request
            • Return a generator of SyncFolderItems
            • Sends the message
            • Register an extended property
            • Send a message to a folder
            • Return the default folder for the given folder
            • Creates the XML payload for a list of items
            • Generate the XML representation of this request
            • Validate and return the cleaned value
            • Generate the payload for a list of folders
            • Return a representation of this EWS
            • Remove attachments from this item
            Get all kandi verified functions for this library.

            exchangelib Key Features

            No Key Features are available at this moment for exchangelib.

            exchangelib Examples and Code Snippets

            The update of exchangelib remove the attribute 'localize' from EWSTimeZone
            Pythondot img1Lines of Code : 3dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            tz_start =  EWSDateTime.from_datetime(dt_start_time).astimezone(tz)
            tz_end =    EWSDateTime.from_datetime(dt_end_time).astimezone(tz)
            
            The update of exchangelib remove the attribute 'localize' from EWSTimeZone
            Pythondot img2Lines of Code : 4dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            EWSDateTime(2017, 9, 5, 8, 30, tzinfo=EWSTimeZone('Europe/Copenhagen'))
            
            EWSDateTime.strptime("2022-03-13", "%Y-%m-%d")
            
            How do I process email from timestamp with exchangelib?
            Pythondot img3Lines of Code : 7dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from dateutil.parser import parse
            
            timestampdate = "2022-02-07 18:16:45+00:00"
            recentkey = parse(timestampdate)
            
            recent_emails = account.inbox.filter(datetime_received__gt = recentkey) ##__gt and gte for greater than or greater than or equ
            Select single file from multiple downloaded file from an email using exchangelib
            Pythondot img4Lines of Code : 5dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            file_attachments = [a for a in item.attachments if isinstance(a, FileAttachment)]
            second_attachment = file_attachments[1]
            # Or:
            last_attachment = file_attachments[-1]
            
            How to install PIP packages through a proxy?
            Pythondot img5Lines of Code : 12dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'my_package'])
            
            subprocess.check_call([
                sys.executable, 
                '-m',
                'pip',
                'install',
                '--proxy',
                'http://10.11.111.11:3128',
                'my_
            Get email_address's from item.cc_recipients exchangelib
            Pythondot img6Lines of Code : 2dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            print([m.email_address for m in item.cc_recipients])
            
            Changing timezone from EWS datetime_received from standard to +2
            Pythondot img7Lines of Code : 13dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from exchangelib import Credentials, Account
            from datetime import datetime
            
            import pytz
            
            credentials = Credentials(email, password)
            acc = Account(email, credentials=credentials, autodiscover=True)
            tz = pytz.timezone('Europe/Amsterdam')
            
            fo
            Changing timezone from EWS datetime_received from standard to +2
            Pythondot img8Lines of Code : 7dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import pytz
            from datetime import datetime
            
            ts = datetime.now()
            tz = pytz.timezone('Etc/GMT+2')
            print(ts.astimezone(tz))
            
            Exchangelib: Filtering email by conversation_id
            Pythondot img9Lines of Code : 23dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from exchangelib.properties import ID_FORMATS, EWS_ID, AlternateId
            
            i = '7FD7341602EE405193F1F996D7DD8D6A'
            for fmt in ID_FORMATS:
                res = list(account.protocol.convert_ids([
                    AlternateId(
                        id=i, format=fmt,
                        
            Python run script upon mail reception
            Pythondot img10Lines of Code : 46dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            Sub OffensiveWords(Item As MailItem)
            
            Dim arrSpam As Variant
            Dim strBody As String
            Dim i As Long
            
            strBody = Item.Subject & " " & Item.Body
            
            ' Set up the array - use lower case
            arrSpam = Array("funded", "ppp", "loan", "funding", "wo

            Community Discussions

            QUESTION

            The update of exchangelib remove the attribute 'localize' from EWSTimeZone
            Asked 2022-Mar-15 at 13:15

            I was using an old version of the library exchangelib. All was fine with my code until some users of my App start to have some issues. Long story short, I had to install for me and the rest of us the last version of exchangelib exchangelib==4.7.2

            So my question is: how can I replace the method: tz.localize(EWSDateTime.from_datetime(dt_start_time)) to filter the emails in my INBOX (or else)

            Please find a small part of the code so it will be easier to read:

            ...

            ANSWER

            Answered 2022-Mar-15 at 13:12

            Newer versions of exchangelib have an implementation of timezones that support directly assigning a timezone to a date:

            Source https://stackoverflow.com/questions/71481225

            QUESTION

            exchangelib: Sending an email as a distribution list
            Asked 2022-Feb-24 at 08:07

            I'm using the exchangelib python EWS library to send emails. Sending from my mailbox works as expected but how can I send an email from a distribution list I have "Send As" permissions already applied (Have tested in Outlook changing the from address)?

            The below code snippet will send the email but "me@domain.com" account shows as the sender. If I change "access_type=DELEGATE" to "access_type=IMPERSONATION", I receive an error "ErrorNonExistentMailbox: The SMTP address has no mailbox associated with it.".

            ...

            ANSWER

            Answered 2022-Feb-24 at 08:07

            A distribution list usually doesn't have its own mailbox in Exchange, so you can't use its email address as primary_smtp_address for the account.

            Messages have both a sender and an author field. You could try to set the distribution list email in the author field. Then emails may show up as coming from that email address.

            Source https://stackoverflow.com/questions/71237266

            QUESTION

            Access Outlook office mailbox(mails in inbox) using python code through EWS
            Asked 2022-Feb-09 at 22:47

            I was reading the Outlook mails through EWS using python exchangelib module

            credentials I was using for authentication: email & app password

            Due to some security reasons the platform team have disabled the App password feature and I ended up accessing the mail box as am not sure how to access mail box without App password ???

            If there is any alternative to App password please suggest me..

            Note: My python script was running in Linux VM

            ...

            ANSWER

            Answered 2022-Feb-09 at 22:47

            When you use an email & app password this is using Basic Authentication which is why your platform team has disabled it. You need to move to using oAuth https://ecederstrand.github.io/exchangelib/#oauth-authentication and make use of the client_credentials flow https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow. So you then use a client secret or certificate rather then username & pword. When using this flow you need to make sure you impersonate the Mailbox your trying to access and also don't use Autodiscover because that will fail with that flow. By default this will give you access to all mailboxes in a tenant so if this is a problem you can scope it down to just the mailboxes you need to access https://techcommunity.microsoft.com/t5/exchange-team-blog/application-access-policy-support-in-ews/ba-p/2110361

            Source https://stackoverflow.com/questions/71051523

            QUESTION

            Exchangelib read emails from a service account without personal login
            Asked 2022-Feb-07 at 14:31

            I would like to read the inbox of a shared service account. The service account inbox is a shared inbox and does not have a password per-se. I can log in and read my personal inbox using this:

            ...

            ANSWER

            Answered 2022-Feb-07 at 14:28

            If you don't want to access the shared account using a personal account, you should create a service account in Exchange and use that to login instead.

            You cannot access the shared account without some sort of authentication.

            Source https://stackoverflow.com/questions/71019505

            QUESTION

            How to get the original recipient of a MeetingRequest using Python exchangelib?
            Asked 2022-Jan-31 at 14:00
            The scenario

            In our scenario we have:

            • a manager mailbox (manager@xxx.yyy)
            • many resource mailboxes (resource_a@xxx.yyy, resource_b@xxx.yyy...)

            Resource mailboxes are setup so that their meeting requests are forwarded to the manager mailbox. The manager will accept or decline on behalf of the resource.

            Our python script connects to the manager account using exchangelib, get the meeting requests and is supposed to accept or to decline depending on rules that are resource specific.

            The problem

            Our problem is that we can't find a way to know which resource is a MeetingRequest related to.

            What we have tried so far

            The to_recipients field's value is manager@xxx.yyy so it doesn't help.

            The author and sender fields' values are the mailbox which has created the original meeting so it doesn't help either.

            We can't rely upon required_attendees or optional_attendees for 2 reasons:

            1. There always are peoples' email addresses in the attendees in addition to the resource and our script can't differentiate a resource email address from other email addresses.
            2. There can be more than one resource for the same meeting. In such a case there will be a meeting request for each resource, each with all the resources in the attendees.

            According to MS doc MeetingRequest should have a ReceivedRepresenting field which seems to be exactly what we need. Unfortunately it is not present in the exchangelib MeetingRequest object although it is in the XML response from EWS when getting the meeting request (we can see it by unabling exchangelib debug logging).

            ...

            ANSWER

            Answered 2022-Jan-31 at 14:00

            ReceivedRepresenting is not mentioned in the EWS documentation on MeetingRequest Does your MeetingRequest XML element contain such a child element? If it does, then please open an issue at ecederstrand/exchangelib and I'll have the field implemented.

            UPDATE: I've opened a pull request against EWS docs to have this field added. And committed a change to support the field in exchangelib. It's released in v4.7.2.

            Source https://stackoverflow.com/questions/70877806

            QUESTION

            Select single file from multiple downloaded file from an email using exchangelib
            Asked 2022-Jan-22 at 19:55

            I m new to python, I m working on extracting text from .pdf and Docx after downloading files from an email using exchangelib but one email format has 2 attachments and I want to select only 2nd file.

            ...

            ANSWER

            Answered 2022-Jan-22 at 19:55

            You're selecting the first element in the file name string, i.e. the second letter in the filename. You want to get the second element of item.attachments instead.

            Assuming you want to only get the second attachment of file attachments, not any attachment, you'll need to filter the list first. something like this:

            Source https://stackoverflow.com/questions/70632254

            QUESTION

            How to install PIP packages through a proxy?
            Asked 2021-Nov-28 at 17:35

            I have RHEL 8 server which has not internet connection and the server has a jupyter notebook installed. I need to install exchangelib module there. Since the server has no any internet connection I couldn't do that. So I started to create a proxy like below.

            ...

            ANSWER

            Answered 2021-Nov-28 at 17:35

            You shouldn't use pip as a library. pip project recommends using it with subprocess call.

            Source https://stackoverflow.com/questions/70145813

            QUESTION

            requests/exchangelib SSLError - hostname 'outlook.office.de' doesn't match either of
            Asked 2021-Nov-07 at 19:27

            I'm having problems connecting to the Microsoft Exchange. It started recently. The problem is that I'm not sure where to look for the solutions.

            The problem is that I'm trying to connect to office.de but the certificate seems not to include this domain now.

            Where to look for the solution/bug?:

            1. My PC (Ubuntu 20.04)
            2. python requests
            3. python exchangelib
            4. Microsoft certificate (temporary issue)

            Traceback:

            ...

            ANSWER

            Answered 2021-Nov-07 at 19:27

            The problem is that I'm trying to connect to office.de but the certificate seems not to include this domain now.

            This is correct. A check with the browser will show that this is not a problem of Python but that the site is setup this way, i.e. the browser will complain too.

            While officially documented for use at Office 365 Germany endpoints it looks like the domain office.de is not setup for use with HTTPS with this domain name.

            Since outlook.office.de is currently just an alias (DNS CNAME) for outlook.office.com my guess is that the documented domains are not intended for direct access by HTTPS, but that they are only documented to get the necessary IP ranges. Internally MS Exchange will likely use the office.com domain instead and thus successfully match the certificates.

            Source https://stackoverflow.com/questions/69875773

            QUESTION

            Library error on docker container (AWS Lambda)
            Asked 2021-Sep-16 at 14:45

            I'm looking to execute a python script on AWS Lambda using a Docker container loaded on AWS ECR. I've managed to create a docker container starting from the amazon image they recommend using for a python script. This is the Dockerfile:

            ...

            ANSWER

            Answered 2021-Sep-16 at 14:45

            Lambda does not support parallel processing for all runtimes. This could be why it's working local but not in lambda.

            https://aws.amazon.com/blogs/compute/parallel-processing-in-python-with-aws-lambda/

            Source https://stackoverflow.com/questions/69193726

            QUESTION

            Changing timezone from EWS datetime_received from standard to +2
            Asked 2021-Sep-13 at 17:24

            I'm trying to change the timezone from UTC+0 to GMT+2. I have tried a lot but i just can't figure it out any help would be amazing

            ...

            ANSWER

            Answered 2021-Sep-13 at 10:35

            You can use pytz to display datetime objects in different timezones.

            example:

            Source https://stackoverflow.com/questions/69160174

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install exchangelib

            You can install using 'pip install exchangelib' or download it from GitHub, PyPI.
            You can use exchangelib like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            Documentation is available at [https://ecederstrand.github.io/exchangelib/](https://ecederstrand.github.io/exchangelib/). Source code documentation is available at [https://ecederstrand.github.io/exchangelib/exchangelib/](https://ecederstrand.github.io/exchangelib/exchangelib/).
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install exchangelib

          • CLONE
          • HTTPS

            https://github.com/ecederstrand/exchangelib.git

          • CLI

            gh repo clone ecederstrand/exchangelib

          • sshUrl

            git@github.com:ecederstrand/exchangelib.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link