4

I've been trying for some time now to connect to Outlook mailbox exchange using Python EWS client.

Problem is, I keep getting 401 authorisation errors when I connect.

I can successfully access the account on my browser via OWA by going to https://webmail.mydomain.com and logging in using some of the details below. But I've tried almost every permutation of user names, UPN etc, using autodiscover etc in my script but no luck :-( Any help would be greatly appreciated. p.s Merry Xmas :-)

Email: username@mydomain.com

UserName: username

Password: password

server: webmail.mydomain.com

from exchangelib import DELEGATE, IMPERSONATION, Account, Credentials, \
    EWSDateTime, EWSTimeZone, Configuration, NTLM, CalendarItem, Message, \
    Mailbox, Q
from exchangelib.folders import Calendar, ExtendedProperty, FileAttachment, ItemAttachment, \
    HTMLBody

config = Configuration( server='webmail.mydomain.com',
            credentials=Credentials(username='username@mydomain.com', password='password'),
            auth_type=NTLM)

account = Account(primary_smtp_address='username@mydomain.com',
            config=config,
            access_type=DELEGATE)
Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63
Phillip Watts
  • 365
  • 3
  • 9
  • check the accepted answer to: [Connect to Exchange mailbox with Python](http://stackoverflow.com/a/3072491/2063361), and also [this](http://stackoverflow.com/a/3072491/2063361) one. Will these helped? – Moinuddin Quadri Dec 23 '16 at 13:18
  • Yep been through these. I'm wondering if I have the username correct - I'm not sure what my "'MYWINDOMAIN\\myusername'" would be. I've tried the UPN without any luck! – Phillip Watts Dec 23 '16 at 14:15

1 Answers1

4

I had been told an incorrect MYWINDOMAIN. Used the correct one and it worked!

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
Phillip Watts
  • 365
  • 3
  • 9