I am reading mails from Exchange server by using c# with below code i am getting an error like Microsoft.Exchange.WebServices.Data.ServiceRequestException: 'The request failed. The remote server returned an error: (401) Unauthorized.'
and when i googled i got information like microsoft stopped direct authentication and now we have to use Open Authenticaion(Oauth).I was going through the steps mentioned in the link OauthToken There in the first step Registration process ,i logged in through my office id and in the search box, i searched App registrations where i am getting Warning like Your administrator has disabled the App registrations experience in the Azure portal. You can still register or manage applications using PowerShell or another client such as Visual Studio.
and i got stuck here?So my question what would be the next step and is this a correct process?
Code used is as below
ExchangeService _service = new ExchangeService(Microsoft.Exchange.WebServices.Data.ExchangeVersion.Exchange2010_SP2); // Use your Exchange version
_service.Credentials = new WebCredentials("[email protected]", "testpwd", "hoeng");
_service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"); // Use your EWS endpoint
Microsoft.Exchange.WebServices.Data.PropertySet propSet = new Microsoft.Exchange.WebServices.Data.PropertySet(BasePropertySet.FirstClassProperties);
propSet.Add(ItemSchema.MimeContent);
propSet.Add(ItemSchema.TextBody);
FolderView view = new FolderView(100);
FindFoldersResults findFolderResults = _service.FindFolders(WellKnownFolderName.Root, view);
foreach (EmailMessage email in _service.FindItems(WellKnownFolderName.Inbox, new ItemView(10)))
{
var message = EmailMessage.Bind(_service, email.Id, propSet);
}