Thank you for posting your query on Microsoft Q&A.
It is likely that your organization has IMAP blocked, as this is considered a legacy protocol and it is encouraged to keep it disabled.
Also if your account uses MFA it is not possible to complete this when using IMAP so it will always fail.
I would suggest to use a webmail solution which supports modern authentication, or else you would need to modify your Exchange Online mailbox to allow IMAP and bypass MFA. We have some details on this here - https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/pop3-and-imap4/pop3-and-imap4
Let me know if you have any further queries, I would be happy to help.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.