After logging in to your mailbox, go to your Microsoft account
Go to the Security tab
Make sure you have two-factor authentication enabled
Next, go to the Advanced security options section
Scroll to the App passwords section and generate a new app password