0
votes

I'm getting above error message while connecting to Office365 .

  ExchangeService serviceInstance = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
  serviceInstance.Credentials = new WebCredentials("[email protected]", "Password", "REDMOND"); 
  serviceInstance.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
   foreach (EmailMessage email in serviceInstance.FindItems(WellKnownFolderName.Inbox, new ItemView(100)))
     {

     }

Both Username and Pwd are correct but still getting issue.

Kindly suggest.

1

1 Answers

0
votes

You shouldn't be specifying the domain in

serviceInstance.Credentials = new WebCredentials("[email protected]", "Password", "REDMOND");

just use the user account upn only (and that maybe different from the Email Address)

serviceInstance.Credentials = new NetworkCredential("[email protected]", "Password");

or try the down-level format

serviceInstance.Credentials = new NetworkCredential("domain\user", "Password");