ecederstrand / exchangelib Goto Github PK
View Code? Open in Web Editor NEWPython client for Microsoft Exchange Web Services (EWS)
License: BSD 2-Clause "Simplified" License
Python client for Microsoft Exchange Web Services (EWS)
License: BSD 2-Clause "Simplified" License
When iterating over a large mailbox (>5000 mails). Python is starting to get in memory problems. It starts using more than 600 Mb and finally raises a out of memory exception.
account = exchangelib.Account(...)
for item in account.inbox.all():
...
for attachment in item.attachments:
...
Traceback (most recent call last):
File "...\exchangelib\exchangelib\util.py", line 157, in to_xml
File "...\lib\xml\etree\ElementTree.py", line 1335, in XML
xml.etree.ElementTree.ParseError: out of memory: line 1, column 0
I have an Exchange server with misconfigured autodiscover (doesn't return a good response), and your autodiscover never returns, it just runs forever (see more below)... I have been writing Exchange code for Python for a couple of years, and I'd be happy to join your project and then I could fix issues like this.
I found the issue in your code:
util.py line 253
You are using a "while True:" loop, which is dangerous in Python, I had some similar issues with my project. I recommend you put in some type of limit like:
max_loops = 10
i = 0
while i < max_loops:
i += 1
# do stuff
I'm trying to filter a huge email folder by date. I'm working from the filtering example on the main page, but getting an error. Is there a different process for filtering emails? Here's my code:
def processCompleted(processAttachments=False):
folder = account.root.get_folder_by_name('COMPLETED EMAILS')
for idx, message in enumerate(folder.filter(start__range=(EWSDateTime(2016, 12, 1), EWSDateTime(2017, 1, 1)))):
soup = BeautifulSoup(message.body, 'html.parser')
bodyText = re.sub("<!.*-->",'',soup.get_text(), flags=re.S).strip()
Here's the error:
Traceback (most recent call last):
File "C:\Users\XXXX\Desktop\Code\Email\emailTest.py", line 220, in
processCompleted()
File "C:\Users\XXXX\Desktop\Code\Email\emailTest.py", line 142, in processCompleted
for idx, message in enumerate(folder.filter(start__range=(EWSDateTime(2016, 12, 1), EWSDateTime(2017, 1, 1)))):
File "C:\Python35\lib\site-packages\exchangelib\folders.py", line 1951, in filter
return QuerySet(self).filter(*args, kwargs)
File "C:\Python35\lib\site-packages\exchangelib\queryset.py", line 237, in filter
q = Q.from_filter_args(self.folder.class, *args, kwargs) or Q()
File "C:\Python35\lib\site-packages\exchangelib\restriction.py", line 163, in from_filter_args
kwargs_q &= Q({key: value})
File "C:\Python35\lib\site-packages\exchangelib\restriction.py", line 82, in init
self.children.append(self.class({'%s__gte' % field: value[0]}))
File "C:\Python35\lib\site-packages\exchangelib\restriction.py", line 102, in init
self.value = value.astimezone(UTC)
File "C:\Python35\lib\site-packages\exchangelib\ewsdatetime.py", line 52, in astimezone
t = super().astimezone(tz=tz)
ValueError: astimezone() cannot be applied to a naive datetime
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/exchangelib/protocol.py", line 61, in __del__
self.close()
File "/usr/local/lib/python3.4/site-packages/exchangelib/protocol.py", line 67, in close
self._session_pool.get(block=False).close_socket(self.service_endpoint)
AttributeError: 'NoneType' object has no attribute 'get'
Calling __del__
should never fail. There may be other __del__
methods that need fixing.
As far as I can tell, the library does not currently offer a way to get email attachments. Is this a feature that is planned?
First of all, this is an amazing library. Very thankful to all the authors.
So I have a Exchange 2013_SP1 server setup and I am testing failure cases. If I add a configuration with incorrect credentials. It goes in a loop and never returns (at least after 10mins). How do I restrict the number of retries before giving up, especially for the case for incorrect credentials.
Hi, I read as much as possible from the source code to see how are handled extended properties. But I didn't see any explicit way to add extended properties to an item model to retrieve our own extended properties from EWS and operate with those.
For now, with the latest changes, this is the way I'm doing it
class CustomProperty(ExtendedProperty):
property_guid = 'my-guid'
property_name = 'name'
property_type = 'String'
additional_properties = {
'custom_property': (CustomProperty, CustomProperty),
}
CalendarItem.ITEM_FIELDS.update(additional_properties)
CalendarItem.ORDERED_FIELDS += tuple(additional_properties.keys())
Is there a way I missed ? If there's not, I believe it would be a great feature to have a better and more explicit way for it. Because, for example, for now to use the latest version, I've to be very careful with the exchangelib updates to keep my extended properties available.
Hi there,
I am trying to use the module to connect to my company Exchange
I am getting stuck at Configuration call which returns this errors - appears to fail to create SOAP call
import exchangelib as e
user='XXXXX'
password='YYYYYY'
service_endpoint='https://mail.micron.com'
config = e.Configuration(
service_endpoint=service_endpoint,
username=user,
password=password,
verify_ssl=True,
auth_type='NTLM',
Traceback (most recent call last):
File "./e", line 14, in
auth_type='NTLM',
File "/usr/lib/python3.4/site-packages/exchangelib/configuration.py", line 47, in init
verify_ssl=verify_ssl,
File "/usr/lib/python3.4/site-packages/exchangelib/protocol.py", line 158, in call
protocol = super().call(_args, *_kwargs)
File "/usr/lib/python3.4/site-packages/exchangelib/protocol.py", line 191, in init
self.version = Version.guess(self)
File "/usr/lib/python3.4/site-packages/exchangelib/version.py", line 179, in guess
return cls._guess_version_from_service(protocol=protocol, hint=api_version)
File "/usr/lib/python3.4/site-packages/exchangelib/version.py", line 220, in _guess_version_from_service
return cls.get_version_from_service(protocol=protocol, api_version=api_version)
File "/usr/lib/python3.4/site-packages/exchangelib/version.py", line 235, in get_version_from_service
allow_redirects=False)
File "/usr/lib/python3.4/site-packages/exchangelib/util.py", line 353, in post_ratelimited
raise TransportError('Unknown failure\n' + log_msg % log_vals)
exchangelib.errors.TransportError: Unknown failure
Retry: 0
Waited: 0
Timeout: 120
Session: 14124
Thread: 139994368284416
Auth type: <requests_ntlm.requests_ntlm.HttpNtlmAuth object at 0x7f52ed03f550>
URL: https://mail.micron.com
Verify: True
Allow redirects: False
Response time: 0:00:00.487085
Status code: 301
Request headers: {'Accept-Encoding': 'compress, gzip', 'User-Agent': 'python-requests/2.11.1', 'Accept': '/', 'Connection': 'Keep-Alive', 'Content-Length': '448', 'Content-Type': 'text/xml; charset=utf-8'}
Response headers: {'X-Powered-By': 'ASP.NET', 'Pragma': 'no-cache', 'Connection': 'close', 'Location': 'https://mail.micron.com/owa/', 'Content-Length': '0', 'Cache-Control': 'no-cache', 'Server': 'Microsoft-IIS/8.5', 'Date': 'Wed, 07 Sep 2016 22:29:41 GMT'}
Request data: b'<s:Envelope xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><s:Header><t:RequestServerVersion Version="Exchange2016" />/s:Header<s:Body><m:ResolveNames ReturnFullContactData="false"><m:UnresolvedEntry>DUMMY/m:UnresolvedEntry/m:ResolveNames/s:Body/s:Envelope'
Response data:
Hi there,
I see that there's continued development of exchangelib. I'm wondering if there is a plan for what this library is eventually going to be?
Is the aim to completely cover all the operations of EWS? Is there any plan to follow the EWS Managed API? Is there any expectations for contributions if you're accepting them?
I might be spending a bit of time writing some stuff for this library (have a bit of experimentation to do with pull subscriptions in my fork) which I might be able to contribute back. Of course it'll be a lot better if I can write it in a way that fits in with the overall vision.
exchangelib
doesn't yet support getting, setting or changing recurrence info on recurring calendar items.
Short introduction with examples: https://msdn.microsoft.com/en-us/library/office/dn727654(v=exchg.150).aspx
Reference: https://msdn.microsoft.com/en-us/library/office/aa580471(v=exchg.150).aspx
For integration with e.g. /var/mail
backed email readers, a Message
should have a method that emits an RFC822
formatted message. See:
https://docs.python.org/3.5/library/email.message.html#email.message.Message
https://docs.python.org/3.5/library/email.generator.html
https://docs.djangoproject.com/fr/1.10/_modules/django/core/mail/message/
If i want to create an new event, the set_xml_value
method raises an exception. The reason for this exception is the 3rd optional parameter of the Attendee last_response_time
. Default value of this parameter is None
. The method set_xml_value
checks the instance of that value.
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "libs"))
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, Mailbox, Attendee
from exchangelib.services import IdOnly
config = Configuration(username='xxxx', password='xxxx', server='xxxx')
account = Account(primary_smtp_address='xxxx', config=config, autodiscover=False, access_type=DELEGATE)
year, month, day = 2016, 7, 20
tz = EWSTimeZone.timezone('Europe/Copenhagen')
ids = account.calendar.find_items(
start=tz.localize(EWSDateTime(year, month, day)),
end=tz.localize(EWSDateTime(year, month, day+1)),
categories=['Besprechung'],
shape=IdOnly
)
items = account.calendar.get_items(ids)
required_attendes = items[0].required_attendees
calendar_item = CalendarItem(
start=tz.localize(EWSDateTime(year, month, day, 14, 30)),
end=tz.localize(EWSDateTime(year, month, day, 15, 30)),
subject='Test Termin',
body='Hello from Python',
location='devnull',
categories=['Besprechung'],
required_attendees=required_attendes
)
res = account.calendar.add_items([calendar_item]) # Raises an exception
# File "libs/exchangelib/util.py", line 105, in set_xml_value
# raise AttributeError('Unsupported type %s for value %s on elem %s' % (type(value), value, elem))
# AttributeError: Unsupported type <class 'NoneType'> for value None on elem <Element 't:LastResponseTime' at 0x7fd5684b6728>
I'm trying to figure out how to save Outlook Items that are attached to emails (emails attached to emails). For normal file attachments, I simply do something like:
for att in item.attachments:
with open(filename, "wb") as temp:
temp.write(att.content)
However, Outlook Items have no attribute "content" and I therefore have no idea what attribute needs to be written to disk. I'm fairly certain I'm just overlooking something - there is an overwhelming amount of information returned if I print out the attributes of the attachment.
Is there a way to get a binary version of the attachment to save?
As the title, it's better to have a parameter to turn off the ssl verify. Thanks
With two exchange users with different credentials reading the Mailbox fails because the authenticated protocol instance of the first user is reused for the second which fails. Using the username in addition to the server name for the cache key makes Mailbox listing work for two exchange users at the same exchange server. Here is a proposed diff to protocol.py:
def close_connections():
- for server, cached_values in _server_cache.items():
+ for cached_key, cached_values in _server_cache.items():
+ server = cached_key[0] # server, username = cached_key
cached_protocol = Protocol('https://%s/EWS/Exchange.asmx' % server, True, Credentials('', ''))
cached_protocol.close()
...
log.debug('Waiting for _server_cache_lock')
with _server_cache_lock:
- if self.server in _server_cache:
+ _server_cache_key = self.server, self.credentials.username
+ if _server_cache_key in _server_cache:
# Get cached version and auth types and session / thread pools
log.debug("Cache hit for server '%s'", self.server)
- for k, v in _server_cache[self.server].items():
+ for k, v in _server_cache[_server_cache_key].items():
setattr(self, k, v)
...
# Cache results
- _server_cache[self.server] = dict(
+ _server_cache[_server_cache_key] = dict(
version=self.version,
ews_auth_type=self.ews_auth_type,
docs_auth_type=self.docs_auth_type,
After calling save() on an email message, the body of the email changes to the html plain text version of the email. This can only be seen online though, since calling print(message.body)
will give the same result either way.
Code:
from exchangelib import DELEGATE, Account, Credentials, Configuration, NTLM
creds = Credentials(
username = 'abc',
password = 'abc')
config = Configuration(
server = 'abc.com',
credentials = creds,
auth_type = NTLM)
account = Account(
primary_smtp_address = '[email protected]',
config = config,
access_type = DELEGATE)
for message in account.inbox.all():
message.save()
After (the screenshot cuts out the bottom part, but it is equivalent to calling message.body
):
Paging EWS services support specifying the number of items returned in each page via MaxEntriesReturned
on the IndexedPageItemView
element. This defaults to 1000 but should probably be set lower or at least configurable to enable tuning and higher parallelism.
The test suite has a test_paging
test that could benefit from this. I creates 1001 items which puts quite some load on the test server.
I am at version 1.6.2
ERROR:sbudevops.exchange:read_mailbox: Caught exception
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/sbudevops/exchange.py", line 108, in read_mailbox
ids = account.inbox.find_items()
File "/usr/lib/python3.4/site-packages/exchangelib/folders.py", line 787, in find_items
restriction.q,
Thanks!
I just found this library and first of: thanks! I was just about to start with DavMail just to get calendar items to ical (publishing calendar is turned off), with this the memory footprint is a lot smaller!
I already managed to get items from the default calendar, but how do I search for elements in a specific caleder, preferably by name? I'm still new to python and I don't know how account.folders works.
>>> from exchangelib.util import to_xml
>>> to_xml('<?xml version="1.0" encoding="UTF-8"?><foo></foo>', encoding='ascii')
>>> to_xml('foo', encoding='ascii')
TypeError: initial_value must be str or None, not bytes
Hi,
I am trying to list cal event from my exchange account on office365.
from exchangelib import DELEGATE, services
from exchangelib.configuration import Configuration
from exchangelib.account import Account
from exchangelib.ewsdatetime import EWSDateTime, EWSTimeZone
from exchangelib.folders import CalendarItem
year, month, day = 2016, 5, 13
tz = EWSTimeZone.timezone('America/New_York')
calendar_items = []
config = Configuration(username='xxxx\xxxx', password='xxxxx')
account = Account(primary_smtp_address='[email protected]', config=config, autodiscover=True, access_type=DELEGATE)
ids = account.calendar.find_items(
start=tz.localize(EWSDateTime(year, month, day)),
end=tz.localize(EWSDateTime(year, month, day+1)),
shape=services.IdOnly,
)
print(ids)
------------------- error ----------------------------
C:\Users\Alex\Desktop>python Python2ExchnageCal_v2.py
Traceback (most recent call last):
File "Python2ExchnageCal_v2.py", line 1, in
from exchangelib import DELEGATE, services
File "C:\Program Files (x86)\Python26\lib\site-packages\exchangelib__init__.py", line 2, in
from .account import Account
File "C:\Program Files (x86)\Python26\lib\site-packages\exchangelib\account.py", line 79
raise ErrorFolderNotFound('No useable calendar folders') from e
^
SyntaxError: invalid syntax
Thanks
Alex Ross
small piece of code would help.
Instead of always storing to /tmp, use tempfile.gettempdir()
When looping over all items in a folder containing more then 1000 items.
I always get the warning "Unexpected next offset: 0 -> 1000" and don't retrieve all items within the folder.
I'm using Exchange2016 on outlook.office365.com
folder = account.inbox
for item in folder.all():
# Unexpected next offset: 0 -> 1000
Hello,
Can you please, say me if it's possible to install the exchangelib library on Windows and/or Mac os ?
I have tried on Mac os but I have an error
โ-1 ~/Projects/PycharmProjects/exchangelib [master|โ]
10:41 $ sudo python2.7 setup.py install
running install
running bdist_egg
running egg_info
writing requirements to exchangelib.egg-info/requires.txt
writing exchangelib.egg-info/PKG-INFO
writing top-level names to exchangelib.egg-info/top_level.txt
writing dependency_links to exchangelib.egg-info/dependency_links.txt
reading manifest file 'exchangelib.egg-info/SOURCES.txt'
writing manifest file 'exchangelib.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.12-intel/egg
running install_lib
running build_py
creating build/bdist.macosx-10.12-intel/egg
creating build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/init.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/account.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/autodiscover.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/configuration.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/credentials.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/errors.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/ewsdatetime.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/folders.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/protocol.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/restriction.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/services.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/transport.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/util.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
copying build/lib/exchangelib/version.py -> build/bdist.macosx-10.12-intel/egg/exchangelib
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/init.py to init.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/account.py to account.pyc
File "build/bdist.macosx-10.12-intel/egg/exchangelib/account.py", line 100
raise ErrorFolderNotFound('No useable default %s folders' % fld_class.name) from e
^
SyntaxError: invalid syntax
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/autodiscover.py to autodiscover.pyc
File "build/bdist.macosx-10.12-intel/egg/exchangelib/autodiscover.py", line 156
raise AutoDiscoverCircularRedirect('Redirect to same email address: %s' % email) from e
^
SyntaxError: invalid syntax
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/configuration.py to configuration.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/credentials.py to credentials.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/errors.py to errors.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/ewsdatetime.py to ewsdatetime.pyc
File "build/bdist.macosx-10.12-intel/egg/exchangelib/ewsdatetime.py", line 92
raise ValueError('Please add an entry for "%s" in PYTZ_TO_MS_TZMAP' % tz.zone) from e
^
SyntaxError: invalid syntax
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/folders.py to folders.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/protocol.py to protocol.pyc
File "build/bdist.macosx-10.12-intel/egg/exchangelib/protocol.py", line 127
raise TransportError("Server '%s' does not exist" % self.server) from e
^
SyntaxError: invalid syntax
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/restriction.py to restriction.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/services.py to services.pyc
File "build/bdist.macosx-10.12-intel/egg/exchangelib/services.py", line 112
raise SOAPError('SOAP response is not XML: %s' % e) from e
^
SyntaxError: invalid syntax
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/transport.py to transport.pyc
File "build/bdist.macosx-10.12-intel/egg/exchangelib/transport.py", line 131
raise ValueError("Authentication type '%s' not supported" % auth_type) from e
^
SyntaxError: invalid syntax
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/util.py to util.pyc
File "build/bdist.macosx-10.12-intel/egg/exchangelib/util.py", line 159
raise ParseError('%s\nOffending text: [...]%s[...]' % (str(e), offending_excerpt)) from e
^
SyntaxError: invalid syntax
byte-compiling build/bdist.macosx-10.12-intel/egg/exchangelib/version.py to version.pyc
File "build/bdist.macosx-10.12-intel/egg/exchangelib/version.py", line 262
raise EWSWarning('Unknown XML response from %s (response: %s)' % (protocol.service_endpoint, r.text)) from e
^
SyntaxError: invalid syntax
creating build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying exchangelib.egg-info/PKG-INFO -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying exchangelib.egg-info/SOURCES.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying exchangelib.egg-info/dependency_links.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying exchangelib.egg-info/not-zip-safe -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying exchangelib.egg-info/requires.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying exchangelib.egg-info/top_level.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
creating 'dist/exchangelib-1.6.2-py2.7.egg' and adding 'build/bdist.macosx-10.12-intel/egg' to it
removing 'build/bdist.macosx-10.12-intel/egg' (and everything under it)
Processing exchangelib-1.6.2-py2.7.egg
removing '/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg' (and everything under it)
creating /Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg
Extracting exchangelib-1.6.2-py2.7.egg to /Library/Python/2.7/site-packages
File "/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg/exchangelib/account.py", line 100
raise ErrorFolderNotFound('No useable default %s folders' % fld_class.name) from e
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg/exchangelib/autodiscover.py", line 156
raise AutoDiscoverCircularRedirect('Redirect to same email address: %s' % email) from e
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg/exchangelib/ewsdatetime.py", line 92
raise ValueError('Please add an entry for "%s" in PYTZ_TO_MS_TZMAP' % tz.zone) from e
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg/exchangelib/protocol.py", line 127
raise TransportError("Server '%s' does not exist" % self.server) from e
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg/exchangelib/services.py", line 112
raise SOAPError('SOAP response is not XML: %s' % e) from e
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg/exchangelib/transport.py", line 131
raise ValueError("Authentication type '%s' not supported" % auth_type) from e
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg/exchangelib/util.py", line 159
raise ParseError('%s\nOffending text: [...]%s[...]' % (str(e), offending_excerpt)) from e
^
SyntaxError: invalid syntax
File "/Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg/exchangelib/version.py", line 262
raise EWSWarning('Unknown XML response from %s (response: %s)' % (protocol.service_endpoint, r.text)) from e
^
SyntaxError: invalid syntax
exchangelib 1.6.2 is already the active version in easy-install.pth
Installed /Library/Python/2.7/site-packages/exchangelib-1.6.2-py2.7.egg
Processing dependencies for exchangelib==1.6.2
Searching for dnspython3>=1.12.0
Reading https://pypi.python.org/simple/dnspython3/
Downloading https://pypi.python.org/packages/f0/bb/f41cbc8eaa807afb9d44418f092aa3e4acf0e4f42b439c49824348f1f45c/dnspython3-1.15.0.zip#md5=ae5118c48c26161a74a8e092b109aa33
Best match: dnspython3 1.15.0
Processing dnspython3-1.15.0.zip
Writing /tmp/easy_install-P2bUEJ/dnspython3-1.15.0/setup.cfg
Running dnspython3-1.15.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-P2bUEJ/dnspython3-1.15.0/egg-dist-tmp-glk1xa
Traceback (most recent call last):
File "setup.py", line 33, in
'Programming Language :: Python :: 3 :: Only',
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Python/2.7/site-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/Library/Python/2.7/site-packages/setuptools/command/install.py", line 117, in do_egg_install
cmd.run()
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 410, in run
self.easy_install(spec, not self.no_deps)
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 646, in easy_install
return self.install_item(None, spec, tmpdir, deps, True)
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 697, in install_item
self.process_distribution(spec, dist, deps)
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 742, in process_distribution
[requirement], self.local_index, self.easy_install
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 853, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 1125, in best_match
return self.obtain(req, installer)
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 1137, in obtain
return installer(requirement)
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 665, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 695, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 876, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 1115, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/Library/Python/2.7/site-packages/setuptools/command/easy_install.py", line 1101, in run_setup
run_setup(setup_script, args)
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 249, in run_setup
raise
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in exit
self.gen.throw(type, value, traceback)
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 197, in setup_context
yield
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in exit
self.gen.throw(type, value, traceback)
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 168, in save_modules
saved_exc.resume()
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 143, in resume
six.reraise(type, exc, self._tb)
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 156, in save_modules
yield saved
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 197, in setup_context
yield
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 246, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 276, in run
return func()
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 245, in runner
_execfile(setup_script, ns)
File "/Library/Python/2.7/site-packages/setuptools/sandbox.py", line 46, in _execfile
code = compile(script, filename, 'exec')
File "/tmp/easy_install-P2bUEJ/dnspython3-1.15.0/setup.py", line 25
"""+"="*78, file=sys.stdout)
^
SyntaxError: invalid syntax
I met an issue while using exchangelib as it is now. For my needs I have to process on every items from my folder (here is the calendar) including the occurrences. However, exchangelib does not provide a way to find items with a CalendarView to list those occurrences but not only the master calendar item.
I believe the CalendarView to a be a major feature for the FindItem operation.
To make it work, I added an argument named calendarview to the service FindItem. If this one is provided, I won't inform the SOAP request with IndexedPageItemView beceause these two don't mix up together.
I'm trying to get AWS WorkMail to play ball with this library, but I keep getting either a 403 Forbidden, or 500 INTERNAL SERVER ERROR.
I've tried using the two setup methods shown in the readme, as well as almost every combination of server/username/auth type I can think of. The trouble is I can't find any WorkMail specific docs anywhere, other than to say that it is a fully EWS-compatible service.
Probably far OT, but I'd be very grateful for any tips/suggestions/knowledge you might be able to impart!
When trying to print a Protocol
object, I get:
Traceback (most recent call last):
File "main.py", line 35, in <module>
print(account.protocol)
File "/usr/exchangelib/exchangelib/protocol.py", line 163, in __str__
self.version.shortname,
AttributeError: 'Version' object has no attribute 'shortname'
Deleting that line (as well as relevant line in the string) raises another error:
Traceback (most recent call last):
File "main.py", line 35, in <module>
print(account.protocol)
File "/usr/exchangelib/exchangelib/protocol.py", line 164, in __str__
self.version.name,
AttributeError: 'Version' object has no attribute 'name'
I switched that line to self.version.fullname,
and it worked. That's the state of my Fork that may be PR'd some time when I've done a few extra things we've needed.
If i want to print all items for the spezific date, the __str__
raises an exception. The reason for this exception is an empty self.__dict__
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "libs"))
from exchangelib import DELEGATE
from exchangelib.account import Account
from exchangelib.configuration import Configuration
from exchangelib.ewsdatetime import EWSDateTime, EWSTimeZone
from exchangelib.services import IdOnly
config = Configuration(username='xxx', password='xxx', server='xxx')
account = Account(primary_smtp_address='xxx', config=config, autodiscover=False, access_type=DELEGATE)
year, month, day = 2016, 7, 20
tz = EWSTimeZone.timezone('Europe/Copenhagen')
ids = account.calendar.find_items(
start=tz.localize(EWSDateTime(year, month, day)),
end=tz.localize(EWSDateTime(year, month, day+1)),
categories=['Besprechung'],
shape=IdOnly,
)
items = account.calendar.get_items(ids)
print(items) # Prints a list of items (OK)
for item in items:
print(item) # Raises an exception
# File "libs/exchangelib/folders.py", line 1119, in __str__
# Extern ID: %(extern_id)s''' % self.__dict__
# KeyError: 'item_id'
Hi,
I've been trying to connect to an inbox for a few days but can't diagnose the problem. I appreciate this may not be an issue with your library but I thought I'd ask the question as I think it's an easy one to answer + it might help others.
Can this library connect to an account if it has no available POP / IMAP / SMTP settings prepared?
(I account can be accessed via OWA as normal.)
I have also wondered if I'm using the correct username 'MYWINDOMAIN\myusername'. If the username is 'davesmith' and email '[email protected]' what should be used here?
Any help is much appreciated!
Phil
I wrote a simple script with exchangelib,
#!/usr/bin/env python3
from pprint import pprint
from exchangelib import DELEGATE
from exchangelib.account import Account
from exchangelib.configuration import Configuration
from exchangelib.services import IdOnly
config = Configuration(
username = 'xx',
password = '...',
service_endpoint = 'https://xxxx/EWS/Exchange.asmx',
verify_ssl = False)
account = Account(
primary_smtp_address = '[email protected]',
config = config)
pprint (account.folders())
However it just stuck. When I press ^C, it shows,
File "./outlook.py", line 13, in <module>
verify_ssl = False)
File "/Users/xxxx/Library/Python/3.5/lib/python/site-packages/exchangelib/configuration.py", line 47, in __init__
verify_ssl=verify_ssl,
File "/Users/xxxx/Library/Python/3.5/lib/python/site-packages/exchangelib/protocol.py", line 158, in __call__
protocol = super().__call__(*args, **kwargs)
File "/Users/xxxx/Library/Python/3.5/lib/python/site-packages/exchangelib/protocol.py", line 191, in __init__
self.version = Version.guess(self)
File "/Users/xxxx/Library/Python/3.5/lib/python/site-packages/exchangelib/version.py", line 179, in guess
return cls._guess_version_from_service(protocol=protocol, hint=api_version)
File "/Users/xxxx/Library/Python/3.5/lib/python/site-packages/exchangelib/version.py", line 220, in _guess_version_from_service
return cls._get_version_from_service(protocol=protocol, api_version=api_version)
File "/Users/xxxx/Library/Python/3.5/lib/python/site-packages/exchangelib/version.py", line 235, in _get_version_from_service
allow_redirects=False)
File "/Users/xxxx/Library/Python/3.5/lib/python/site-packages/exchangelib/util.py", line 312, in post_ratelimited
time.sleep(wait) # Increase delay for every retry
KeyboardInterrupt
How should I debug it? The server_endpoint works in browser.
I have an exchange user with an empty mailbox, exchangelib generates an assertion error which is wrong IMO. Proposed change to folders.py:
def get_items(self, ids):
# get_xml() uses self.with_extra_fields. Pass this to from_xml()
- assert len(ids)
return list(map(
lambda i: self.item_model.from_xml(i, self.with_extra_fields),
GetItem(self.account.protocol).call(folder=self, ids=ids))
Dear author. Thank you for providing such a convenient lib for exchange.
Recently I'm using the lib to create and delete my outlook calendar.
Using this lib, I delete my event in calendar successfully, but when I create the event, it raise a TypeError.
from exchangelib import DELEGATE, IMPERSONATION, Account, Credentials, \
EWSDateTime, EWSTimeZone, Configuration, NTLM, CalendarItem, Message, \
Mailbox, Q
from exchangelib.folders import Calendar, ExtendedProperty, FileAttachment, ItemAttachment, \
HTMLBody
USERNAME = "[email protected]"
PASSWORD = "mypassword"
EWSTimeZone.PYTZ_TO_MS_MAP["Asia/Shanghai"] = 'China Standard Time'
year, month, day = 2016, 12, 26
tz = EWSTimeZone.timezone("Asia/Shanghai")
# 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'],
))
credentials = Credentials(username='USERNAME', password='PASSWORD' , is_service_account=False)
config = Configuration(
server='mail.example.com',
credentials=Credentials(username='USERNAME', password='PASSWORD'),
auth_type=NTLM,
verify_ssl=False,
)
account = Account(primary_smtp_address='USERNAME', config=config,
access_type=DELEGATE)
for event in account.calendar.all():
print(event.subject) # it print the subject of my event
event.delete() # my event has been deleted from my calendar successfully
res = account.calendar.bulk_create(calendar_items) # raise Error
print(res)
The result shows like this:
Test Subject
My Event
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/exchangelib/folders.py", line 2042, in add_items
return self.bulk_create(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/exchangelib/folders.py", line 2045, in bulk_create
return self.account.bulk_create(folder=self, *args, **kwargs)
TypeError: bulk_create() got multiple values for argument 'folder'
How can I fix this. Thank you for your consideration and I will be looking forward to your reply.
Is there a way to send emails via exchange using this library?
Hi,
I am trying to list cal event from my exchange account on office365.
from exchangelib import DELEGATE, services
from exchangelib.configuration import Configuration
from exchangelib.account import Account
from exchangelib.ewsdatetime import EWSDateTime, EWSTimeZone
from exchangelib.folders import CalendarItem
year, month, day = 2016, 5, 13
tz = EWSTimeZone.timezone('US/Eastern')
calendar_items = []
config = Configuration(username='xxxx\xxxx', password='xxxxx')
account = Account(primary_smtp_address='[email protected]', config=config, autodiscover=True, access_type=DELEGATE)
ids = account.calendar.find_items(
start=tz.localize(EWSDateTime(year, month, day)),
end=tz.localize(EWSDateTime(year, month, day+1)),
shape=services.IdOnly,
)
print(ids)
------------------- error ----------------------------
C:\Users\Alex\Desktop>python Python2ExchnageCal_v2.py
Traceback (most recent call last):
File "Python2ExchnageCal_v2.py", line 1, in
from exchangelib import DELEGATE, services
File "C:\Program Files (x86)\Python26\lib\site-packages\exchangelib__init__.py", line 2, in
from .account import Account
File "C:\Program Files (x86)\Python26\lib\site-packages\exchangelib\account.py", line 79
raise ErrorFolderNotFound('No useable calendar folders') from e
^
SyntaxError: invalid syntax
Thanks
Alex Ross
Currently, list()
is needed around a QuerySet
to do slicing. Things like this would be useful and intuitive:
my_folder.filter(...)[0]
my_folder.filter(...)[1:5]
len(my_folder.filter(...))
The simple implementation evaluates the QuerySet (or uses the cache) and does slicing on that. Maybe FindItem
has something like MaxItems
we can use for optimization.
len()
should simply call count()
unless the cache has been populated.
Trying to use the library to fetch unread items from a mailbox. Ran into an issue where if the folder contains meeting requests a KeyError exception occurs.
Simple test:
items = account.inbox.filter(is_read=False)
for item in items:
print('subject: {}, read: {}'.format(item.subject, item.is_read))
Example error message:
<exchangelib.queryset.QuerySet object at 0x7f134dfec7f0>
Traceback (most recent call last):
File "ews.py", line 30, in <module>
for item in items:
File "/home/alex/src/django-dashing-test/venv/lib/python3.5/site-packages/exchangelib/queryset.py", line 125, in __iter__
self._cache = list(self._query())
File "/home/alex/src/django-dashing-test/venv/lib/python3.5/site-packages/exchangelib/queryset.py", line 97, in _query
items = self.folder.fetch(ids=ids, only_fields=additional_fields)
File "/home/alex/src/django-dashing-test/venv/lib/python3.5/site-packages/exchangelib/folders.py", line 1585, in fetch
return self.account.fetch(folder=self, *args, **kwargs)
File "/home/alex/src/django-dashing-test/venv/lib/python3.5/site-packages/exchangelib/account.py", line 312, in fetch
items
File "/home/alex/src/django-dashing-test/venv/lib/python3.5/site-packages/exchangelib/account.py", line 311, in <lambda>
lambda i: validation_folder.item_model_from_tag(i.tag).from_xml(elem=i, account=self, folder=folder),
File "/home/alex/src/django-dashing-test/venv/lib/python3.5/site-packages/exchangelib/folders.py", line 1419, in item_model_from_tag
return cls.ITEM_MODEL_MAP[tag]
KeyError: '{http://schemas.microsoft.com/exchange/services/2006/types}MeetingRequest'
As far as I understood it from the source no MeetingRequest class has not been implemented yet. Is there a reason why it's missing or have I missed something?
I hacked together a bare minimum version of the various meeting requests types and got it working. I could implement more of the meeting types and create a pull request, just wanted to verify if I'm on the right track?
Example implementation:
class MeetingRequest(ItemMixIn):
# Supported attrs: https://msdn.microsoft.com/en-us/library/office/aa565229(v=exchg.150).aspx
ELEMENT_NAME = 'MeetingRequest'
FIELDURI_PREFIX = 'meetingrequest' # educated guess
ITEM_FIELDS = {
'from': ('From', Mailbox),
'is_read': ('IsRead', bool),
'start': ('Start', EWSDateTime),
'end': ('End', EWSDateTime),
}
ORDERED_FIELDS = (
'subject', 'from', 'is_read', 'start', 'end'
)
REQUIRED_FIELDS = {'subject'}
READONLY_FIELDS = {'from'}
__slots__ = tuple(ITEM_FIELDS) + tuple(Item.ITEM_FIELDS)
def __init__(self, **kwargs):
for k in self.ITEM_FIELDS:
field_type = self.ITEM_FIELDS[k][1]
default = False if (k in self.required_fields() and field_type == bool) else None
v = kwargs.pop(k, default)
setattr(self, k, v)
super().__init__(**kwargs)
Repeatedly getting this traceback, but we should invalidate the cache and retry if get get AutoDiscoverFailed in this code path.
Traceback (most recent call last):
File "test.py", line 24, in <module>
a = Account(primary_smtp_address=email, credentials=c, access_type=DELEGATE, autodiscover=True, verify_ssl=False)
File "/lib/python3.4/site-packages/exchangelib/account.py", line 43, in __init__
credentials=credentials, verify_ssl=verify_ssl)
File "/lib/python3.4/site-packages/exchangelib/autodiscover.py", line 155, in discover
protocol=protocol)
File "/lib/python3.4/site-packages/exchangelib/autodiscover.py", line 296, in _autodiscover_quick
r = _get_autodiscover_response(protocol=protocol, email=email)
File "/lib/python3.4/site-packages/exchangelib/autodiscover.py", line 354, in _get_autodiscover_response
raise AutoDiscoverFailed('No access to %s using %s' % (protocol.service_endpoint, protocol.auth_type))
exchangelib.errors.AutoDiscoverFailed: No access to https://autodiscover.example.com/Autodiscover/Autodiscover.xml using NTLM
Is it possible to change the is_read
field of a message and save the modified Message object?
Traceback (most recent call last):
File "owa-notifier.py", line 32, in <module>
for msg in a.inbox.filter(datetime_received__gt=six_hours_ago).only('datetime_received', 'subject').order_by('-datetime_received',):
File ".virtualenvs/owa-notifier/lib/python3.4/site-packages/exchangelib/queryset.py", line 125, in __iter__
self._cache = list(self._query())
File ".virtualenvs/owa-notifier/lib/python3.4/site-packages/exchangelib/queryset.py", line 99, in _query
items = self.folder.find_items(self.q, additional_fields=additional_fields, shape=IdOnly)
File ".virtualenvs/owa-notifier/lib/python3.4/site-packages/exchangelib/folders.py", line 1521, in find_items
raise ValueError("'%s' is not a field on %s" % (f, self.supported_item_models))
ValueError: '-datetime_received' is not a field on (<class 'exchangelib.folders.Message'>,)
Also, there is inconsistent use of sets and tuples in the beginning of _query()
Fresh install on an Ubuntu and Windows box. Keep getting the same issue. 2.7 and 3.5
Tried UTC, US/Pacific, Mountain Standard Time
Traceback (most recent call last):
File "exch.py", line 1, in <module>
from exchangelib import DELEGATE, IMPERSONATION, Account, Credentials, EWSDateTime, EWSTimeZone, Configuration, NTLM, CalendarItem, Message, Mailbox, Q
File "/usr/local/lib/python2.7/dist-packages/exchangelib-1.7.4-py2.7.egg/exchangelib/__init__.py", line 1, in <module>
from .account import Account
File "/usr/local/lib/python2.7/dist-packages/exchangelib-1.7.4-py2.7.egg/exchangelib/account.py", line 15, in <module>
from .folders import Root, Calendar, DeletedItems, Drafts, Inbox, Outbox, SentItems, JunkEmail, Tasks, Contacts, \
File "/usr/local/lib/python2.7/dist-packages/exchangelib-1.7.4-py2.7.egg/exchangelib/folders.py", line 20, in <module>
from .ewsdatetime import EWSDateTime, UTC, UTC_NOW
File "/usr/local/lib/python2.7/dist-packages/exchangelib-1.7.4-py2.7.egg/exchangelib/ewsdatetime.py", line 103
raise ValueError('PYTZ_TO_MS_MAP value %s must be a key in MS_TIMEZONE_DEFINITIONS' % self_cls.ms_id) from e
^
SyntaxError: invalid syntax
Hi,
I have been successfully copy-pasting code from your examples which send e-mails. I do not require a lot - I just want to send an e-mail. (I will work on reading it later). My Python knowledge is modest - basic stuff and Lego programming (programming using blocks someone else made :)).
My tests were working fine until I have tried up replicate this on a host which was newly built and using 1.7.2 version when I started getting this exception:
m.send() # Or m.send_and_save() if you want a copy in the 'Sent' folder
File "C:\Program Files\Python35\lib\site-packages\exchangelib-1.7.1-py3.5.egg\exchangelib\folders.py", line 1201, in send
raise ValueError('Item must have an account')
ValueError: Item must have an account
My code:
`
from exchangelib.folders import Message, Mailbox
from exchangelib import DELEGATE, IMPERSONATION, Account, Credentials,
EWSDateTime, EWSTimeZone, Configuration, NTLM, Q
from exchangelib.folders import Calendar
import locale
email = '[email protected]'
locale.setlocale(locale.LC_ALL, '')
credentials_in = Credentials(username='DOMAIN\\username', password='secret')
config = Configuration(
server='email.com',
credentials=credentials_in,
auth_type=NTLM
)
a = Account(primary_smtp_address=email, config=config,
access_type=DELEGATE)
m = Message(
folder=a.sent,
subject='Daily motivation',
body='All bodies are beautiful',
to_recipients=[Mailbox(email_address='[email protected]')])
m.send() # Or m.send_and_save() if you want a copy in the 'Sent' folder
`
I started comparing commits, but, thought that you might have somewhere to check this better (and faster).
util.xml_text_to_value()
is used by from_xml()
to convert from text to the correct Python class instance. We should return e.g. AnyURI and Body instances when given this str
-derived field_type
.
Hi,
I am trying to connect to my company's Exchange server with exchangelib. For this I need to use certificates for authentication.
config = Configuration(
server=''company-server.com,
credentials=Credentials(username='domain\\username', password='password'),
auth_type=NTLM,
verify_ssl="certificate.cer"
)
When I run the code above, I get:
SSLError: unknown error (_ssl.c:2728)
Can you please let me know how to use certificates with exchangelib? Alternatively, is there anyway I can use my own requests.Session() object with exchnagelib?
Vlad
import exchangelib
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.2/dist-packages/exchangelib/init.py", line 2, in
from .account import Account
File "/usr/local/lib/python3.2/dist-packages/exchangelib/account.py", line 3, in
from .autodiscover import discover
File "/usr/local/lib/python3.2/dist-packages/exchangelib/autodiscover.py", line 26, in
from .version import API_VERSIONS
File "/usr/local/lib/python3.2/dist-packages/exchangelib/version.py", line 8, in
from .transport import TNS, SOAPNS, dummy_xml, get_auth_instance
File "/usr/local/lib/python3.2/dist-packages/exchangelib/transport.py", line 10, in
from .util import create_element, add_xml_child, is_xml, get_redirect_url
File "/usr/local/lib/python3.2/dist-packages/exchangelib/util.py", line 5, in
from threading import get_ident
ImportError: cannot import name get_ident
I have a backport of this project supporting Python 2.7, would this be interesting to merge back?
The backporting involved:
If this is of interest I will open a PR, you can review the fork at https://github.com/TheFarm/exchangelib
Dear, author, now I'm using the exchangelib to create a multi-user event.
After creating the calendar item, the item shows up in the sender's calendar. But the calendar item doesn't show up in the receivers's calendar.
The receiver's mailbox is in the sender's calendar with no response . But the receiver didn't receive any calendar or email.
Here is my code:
required_attendees = account.calendar.all()[0].required_attendees
attendee = required_attendees[0]
print(require_attendees) # [Attendee(Mailbox('username', '[email protected]', 'Mailbox', None), 'Unknown', None)]
organizer = account.calendar.all()[0].organizer
print(organizer) # Mailbox('sender', '[email protected]', 'Mailbox', 'None)
calendaritem = 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'],
account = account,
folder = account.calendar,
organizer = organizer,
# required_attendees = required_attendees
required_attendees = [attendee],
)
calendaritem.save()
I also tried to change the response_type to other values of attendee.RESPONSE_TYPES
and save the item again. But none of them show up in the receiver's calendar.
I know that you are inconvenient to test the Meeting invitations and required/optional attendees. I'm glab to assistance you as far as possible. I'm looking forward to your reply.
I'm noticing when I pull emails from the server, not all of the conversation is always available in the message body. However, when there is content missing, it's typically available in the attachments as a message. How can I access the message functions when it's in a FileAttachment?
Looking at the FileAttachment content looks something like this:
FileAttachment(Message(is_response_requested=False, is_read_receipt_requested=False, is_delivery_receipt_requested=False, is_read=True, sender=...
I'm trying to access a folder inside my account called 'Undeliverable' and get a list of the emails inside and see if they have attachments.
I've successfully retrieved a list of all the folders in my account and 'Undeliverable' is listed in the response.
I did a:
for i in account.folders:
... print(i)
Now, that code shows <class 'exchangelib.folders.Root'>. that's where all the folders I've created live.
How do I get inside the array that Root contains to then do something akin to:
account.inbox.Root['Undeliverable].find_items() and get all the data associated with that email, attachments and all?
I've done some investigation in the python prompt but I can't seem to getr inside the folder designated Root.
Currently, This is as far as I've gotten:
from exchangelib import DELEGATE
from exchangelib.account import Account
from exchangelib.configuration import Configuration
from exchangelib.services import IdOnly
from exchangelib import DELEGATE, IMPERSONATION, Account, Credentials, EWSDateTime, EWSTimeZone, Configuration, NTLM, CalendarItem, Q
from exchangelib.folders import Folder
credentials = Credentials(username='XXXXXX\XXXXXX', password='XXXXXX')
account = Account(primary_smtp_address='XXX@XXX', credentials=credentials, autodiscover=True, access_type=DELEGATE)
# Get Exchange ID and changekey of all inbox items
ids = account.inbox.find_items(shape=IdOnly)
# Get the rest of the attributes on the items
items = account.inbox.get_items(ids)
print(len(items))
for i in account.folders:
print(i)
Thanks,
Bryan James
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.