title: Error 403 while using exchangelib to access Outlook Exchange server to read emails
body: <p>I'm trying to read emails from the Microsoft Exchange server using EWS and exchangelib in Python for an email classification problem. But I am unable to connect to the exchange server.</p>
  
  <p>I've tried specifying the version, auth_type, using a certificate (which gives a ssl verify error), using the smtp address in place of the username and it still doesn't connect.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>from exchangelib import Credentials, Account, EWSDateTime, EWSTimeZone, Configuration, DELEGATE, IMPERSONATION, NTLM, ServiceAccount, Version, Build
  
  USER_NAME = 'domain\\user12345'
  ACCOUNT_EMAIL = john.doe@ext.companyname.com'
  ACCOUNT_PASSWORD = 'John@1234'
  ACCOUNT_SERVER = 'oa.company.com'
  
  creds = Credentials(USER_NAME, ACCOUNT_PASSWORD)
  config = Configuration(server=ACCOUNT_SERVER, credentials=creds)
  account = Account(primary_smtp_address=ACCOUNT_EMAIL, config=config, autodiscover=False, access_type=DELEGATE)
  
  print('connecting ms exchange server account...')
  print(type(account))
  
  print(dir(account))
  account.root.refresh()
  </code></pre>
  
  <p>Here is the error I am getting:</p>
  
  <pre><code>TransportError: Unknown failure
  Retry: 0
  Waited: 10
  Timeout: 120
  Session: 26271
  Thread: 15248
  Auth type: &lt;requests_ntlm.requests_ntlm.HttpNtlmAuth object at 0x00000259AA1BD588&gt;
  URL: https://oa.company.com/EWS/Exchange.asmx
  HTTP adapter: &lt;requests.adapters.HTTPAdapter object at 0x00000259AA0DB7B8&gt;
  Allow redirects: False
  Streaming: False
  Response time: 0.28100000000085856
  Status code: 403
  Request headers: {'User-Agent': 'python-requests/2.21.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'Keep-Alive', 'Content-Type': 'text/xml; charset=utf-8', 'Content-Length': '469', 'Authorization': 'NTLM TlRMTVNTUAADAAAAGAAYAG0AAAAOAQ4BhQAAAAwADABYAAAACQAJAGQAAAAAAAAAbQAAABAAEACTAQAANoKJ4gYBsR0AAAAP7Pyb+wBnMdrlhr4FKVqPbklDSUNJQkFOS0xURElQUlUzODE5MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJTLmMBLPHowOJZ46XDs+4ABAQAAAAAAAAZdRefQLNUB+Fc6Z26oxvgAAAAAAgAYAEkAQwBJAEMASQBCAEEATgBLAEwAVABEAAEAEgBIAFkARABFAFgAQwBIADAAOAAEACAAaQBjAGkAYwBpAGIAYQBuAGsAbAB0AGQALgBjAG8AbQADADQASABZAEQARQBYAEMASAAwADgALgBpAGMAaQBjAGkAYgBhAG4AawBsAHQAZAAuAGMAbwBtAAUAIABpAGMAaQBjAGkAYgBhAG4AawBsAHQAZAAuAGMAbwBtAAcACAAGXUXn0CzVAQYABAACAAAACgAQAD9EWlwiiUs304wucsxnkyQAAAAAAAAAALfelDwG05hYOMUqY/e60PY=', 'Cookie': 'ClientId=SINZWMOJKWSKDGEKASFG; expires=Fri, 26-Jun-2020 10:13:02 GMT; path=/; HttpOnly'}
  Response headers: {'Cache-Control': 'private', 'Server': 'Microsoft-IIS/8.5', 'request-id': 'ae4dee8d-34e0-471c-8252-b8c1056c8ea0', 'X-CalculatedBETarget': 'pqrexch05.domain.com', 'X-DiagInfo': 'PQREXCH05', 'X-BEServer': 'PQREXCH05', 'X-AspNet-Version': '4.0.30319', 'Set-Cookie': 'exchangecookie=681afc8a0905459182363cce9a98d021; expires=Sat, 27-Jun-2020 10:13:02 GMT; path=/; HttpOnly, X-BackEndCookie=S-1-5-21-1343024091-725345543-504838010-1766210=u56Lnp2ejJqBy87Iysqem5nSy8mbnNLLyZ7H0sfIysbSy5vMz8qdzcvPnpzHgYHNz87G0s/I0s3Iq87Pxc7Mxc/N; expires=Sat, 27-Jul-2019 10:13:02 GMT; path=/EWS; secure; HttpOnly', 'Persistent-Auth': 'true', 'X-Powered-By': 'ASP.NET', 'X-FEServer': 'PQREXCH05', 'Date': 'Thu, 27 Jun 2019 10:13:01 GMT', 'Content-Length': '0'}
  Request data: b'&lt;?xml version=\'1.0\' encoding=\'utf-8\'?&gt;\n&lt;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"&gt;&lt;s:Header&gt;&lt;t:RequestServerVersion Version="Exchange2013_SP1"/&gt;&lt;/s:Header&gt;&lt;s:Body&gt;&lt;m:ResolveNames ReturnFullContactData="false"&gt;&lt;m:UnresolvedEntry&gt;ICICIBANKLTD\\IPRU38190&lt;/m:UnresolvedEntry&gt;&lt;/m:ResolveNames&gt;&lt;/s:Body&gt;&lt;/s:Envelope&gt;'
  Response data: b''
  </code></pre>