I'm attepting to use MailKit to access the emails in my personal outlook.com account.
I'm using the IMAP settings recommended by Microsoft but when I call _imapClient.Authenticate with my username and password I get a 'LOGON failed' exception returned.
A few sites have directed me to use Oauth2 to authenticate but this requires I register my app in the Azure portal which I don't have access to. My account being a personal one.
private ImapClient _imapClient;
private MailboxConfiguration _mailboxConfiguration;
public ConfiguredMailbox(MailboxConfiguration mailboxConfiguration, CancellationToken cancellationToken)
{
_mailboxConfiguration = mailboxConfiguration;
_imapClient = new ImapClient();
_imapClient.Connect(_mailboxConfiguration.URL, _mailboxConfiguration.Port, true, cancellationToken);
_imapClient.Authenticate(_mailboxConfiguration.Username, _mailboxConfiguration.Password, cancellationToken);
_imapClient.Inbox.Open(FolderAccess.ReadWrite, cancellationToken);
}
If I've previously logged in with a browser, this will work for about a minute. I'm guessing that the token issued to the browser is also being used.
I did try implemeting the Oauth2 method suggested but I just got an error basically saying you can't do this for MSA accounts.