I have been searching for code examples of fetching emails from Hotmail using Mailkit via Imap. Unfortunately, I have not found anything worked for me.
I can see that Hotmail supports Imap now and Microsoft is pushing to use GraphClient to do the job. But I cannot figure out how to connect to Hotmail.
Not sure this is caused by not correct code or I cannot turn on IMAP for my registered app(Web) on Azure.
Every time when I tried to turn it on, it throws this error
IPublicClientApplication _msalClient;
string[] _scopes = new string[2] { "Mail.Read", "User.Read"};
IAccount _userAccount;
_msalClient = PublicClientApplicationBuilder
.Create("xxxxxxxxxxxxxxx")
.WithAuthority(AadAuthorityAudience.AzureAdAndPersonalMicrosoftAccount, true)
.Build();
var result = await _msalClient.AcquireTokenWithDeviceCode(_scopes, callback => {
Console.WriteLine(callback.Message);
return Task.FromResult(0);
}).ExecuteAsync();
return result.AccessToken;