Sorry for my english not being so well: Within a windows domain I try to connect to our exchangeserver (2010/SP3) using the example given on the pypi site:
from exchangelib import DELEGATE, NTLM, Account, Credentials, Configuration
import os, logging
logging.basicConfig(level=logging.DEBUG)
creds = Credentials(
username='mydomain\\my.name',
password='mypassword')
config = Configuration(server='exchange.xxx.local/EWS/Exchange.asmx', credentials=creds)
account = Account(
primary_smtp_address='my.name@mycompany.com',
credentials=creds,
autodiscover=False,
access_type=DELEGATE)
for item in account.inbox.all().order_by('-datetime_received')[:30]:
print(item.subject, item.body, item.attachments)
After starting the script, I get this output in the python console:
DEBUG:exchangelib.protocol:Waiting for _protocol_cache_lock
DEBUG:exchangelib.protocol:Protocol __call__ cache miss. Adding key '('https://exchange.xxx.local/EWS/Exchange.asmx', Credentials('mydomain\\my.name', '********'), True)'
DEBUG:exchangelib.transport:Getting service auth type for https://exchange.xxx.local/EWS/Exchange.asmx
DEBUG:exchangelib.transport:Requesting b'<?xml version="1.0" encoding="utf-8"?><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>mydomain\\my.name</m:UnresolvedEntry></m:ResolveNames></s:Body></s:Envelope>' from https://exchange.xxx.local/EWS/Exchange.asmx
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): exchange.xxx.local
Traceback (most recent call last):
File "C:\CWS\Python-venv\p353-01\lib\site-packages\urllib3\connectionpool.py", line 594, in urlopen
self._prepare_proxy(conn)
File "C:\CWS\Python-venv\p353-01\lib\site-packages\urllib3\connectionpool.py", line 810, in _prepare_proxy
conn.connect()
File "C:\CWS\Python-venv\p353-01\lib\site-packages\urllib3\connection.py", line 294, in connect
self._tunnel()
File "C:\seProg\python353\Lib\http\client.py", line 832, in _tunnel
message.strip()))
OSError: Tunnel connection failed: 407 Proxy Access Denied
... (and many more lines with error messages)
I also tried the other options from the exchangelib site with autodiscover=True and only creds= given (without config=). Without success. I then installed the EWS-Editor from https://ewseditor.codeplex.com/ in order to see, if connection via EWS may work at all in the environment of my company. It works fine with that tool, just have to give it my SMTP-address.
I would very much appreciate any help. Thanks in advance!