0
votes

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.

IMAP

Every time when I tried to turn it on, it throws this error enter image description here

     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;
1

1 Answers

0
votes

This was a temporary issue in our rollout process and is now fixed. You should now be able to add IMAP, POP, SMTP permissions to your app and acquire tokens.