As far as I understood correctly, Microsoft has only allowed OAuth connections for IMAP and SMTP since October 2022 in Micrsosoft 365. The basic authentication only via username and password (also app password) is deactivated. You can apply for an extension, but ultimately this option will be completely deactivated at the beginning of 2023.
Is there an adjustment planned by the developers or is there perhaps an extension? We use Nextcloud for an EU-wide school project. Within the school we use Microsoft 365 for Education, so that our e-mail servers also run on MS 365.