1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Python cannot connect to the Exchange mail server

Discussão em 'Python' iniciado por Stack, Outubro 5, 2024 às 19:42.

  1. Stack

    Stack Membro Participativo

    Good day. I have a problem when I write a Python script to connect to my work mailbox on Microsoft Outlook Web (OWA). Version OS of mailserver is 'Microsoft Windows NT 6.0.6003 Service Pack 2'. I do not have administrator rights to access this mailbox. I only have a username, password, and mail server address. I can freely access this mailbox from any phone or web browser.But when I try to connect to this mailbox using a Python script with exchangelib, I get error "connction failed".

    I tried using the 'exchangelib' library. Below is a piece of my code.

    import exchangelib
    from exchangelib import DELEGATE, Account, Credentials, Message, Mailbox, HTMLBody, Configuration
    creds = Credentials (username = 'usernam@workdomain.**', password = 'pass')
    config = Configuration (credentials = creds, server = 'https://owa.workdomain.**', service_endpoint = None, auth_type = 'basic', version = None, retry_policy = None, max_connections = None)
    account = Account(primary_smtp_address = 'usernam@workdomain.**',fullname = 'usernam', access_type = DELEGATE, autodiscover = False, credentials = creds, config = config, locale = None, default_timezone = None)


    And I get this error:

    raise TransportError(f"No valid version headers found in response ({e!r})")
    exchangelib.errors.TransportError: No valid version headers found in response #(ErrorTimeoutExpired('Reraised from ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded #with url: /owa.*******.**/EWS/Exchange.asmx (Caused by #NameResolutionError("<urllib3.connection.HTTPSConnection object at #0x000001EDF67CBC10>: Failed to resolve 'https' ([Errno 11001] getaddrinfo failed)


    I see that there is an error in the version of the request header, but I do not understand how to #fix it.

    Continue reading...

Compartilhe esta Página