none
Connect to EWS- Exchange Online RRS feed

  • Question

  • Hi all- I have a web application that uses EWS to process some items in a mailbox.  The mailbox is currently on prem but needs to be moved to exchange online.  When testing with an online mailbox, I'm getting a 401 unauthorized when trying to connect to EWS online.  Here's my code:

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
                
    service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
    service.Credentials = new WebCredentials("email@company.com", "password");

    Like I said, I'm getting a 401.  I've confirmed the email/password combo is correct, I am able to sign in directly O365 webmail with it and check the inbox. Does anyone know what I might be missing?

    Monday, February 4, 2019 8:57 PM

All replies

  • I'd suggest you test it with the ewseditor https://github.com/dseph/EwsEditor/releases this allows you to logon using EWS and use either Basic or OAuth Authentication. It's possible that basic auth has been turned off in the tenant and you will need to use oAuth else you just have an issue with you code.

    Cheers
    Glen

    Monday, February 4, 2019 11:31 PM