+1 vote

During the day today we have detected problems with the library, the error message that we get is the following:

Error message: User is authenticated but not connected:

Mail.dll: 16:47:20 0425 Connecting to 'outlook.office365.com:993', SSL/TLS: True.
Mail.dll: 16:47:20 0425 S: * OK The Microsoft Exchange IMAP4 service is ready.
....
Mail.dll: 16:47:45 0425 C: 04250002 AUTHENTICATE XOAUTH2 dXNlcj1l....XXX
Mail.dll: 16:47:46 0425 S: 04250002 OK AUTHENTICATE completed.
Mail.dll: 16:47:46 0425 C: 04250003 CAPABILITY
Mail.dll: 16:47:46 0425 S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CLIENTACCESSRULES CLIENTNETWORKPRESENCELOCATION BACKENDAUTHENTICATE CHILDREN IDLE NAMESPACE LITERAL+
Mail.dll: 16:47:46 0425 S: 04250003 OK CAPABILITY completed.
Mail.dll: 16:47:46 0425 C: 04250004 LIST "" ""
Mail.dll: 16:47:46 0425 S: 04250004 BAD User is authenticated but not connected.

We are using IMAP with OAuth2 (client credential flow), it authenticates us but does not connect, we have access to the mailbox via the web.

The password and the credentials are correct since it authenticates correctly; it's an issue of not connecting.

We are making connections every 5 minutes.

It has not given us problems until early this morning when the connection error has started to jump.

You can give us support, we have had the service stopped for an hour and it is something urgent that we need to solve as soon as possible.

ago by

1 Answer

0 votes
 
Best answer

This error comes from Office365 server, not Mail.dll itself. It is the server that prevents you to access this mailbox.

1.
Log-in via the web UI to this mailbox - there might be a some policy update information dialog, that you need to confirm.
(You have already done that)

2.
Are you connecting too frequently? It is a Microsoft's mechanism to shut down chatty clients.
(5 minutes interval is most likely OK)

3.
Is it a shared mailbox?
Does your user have access to the mailbox you want to access?
Hence the authenticated (application) and not connected (mailbox)
In other words: you most likely messed up or skipped the step "Add permissions to a specific mailbox" (which can take up to half an hour to take effect)

4.
Have you checked permissions for your mailbox?

Connect-ExchangeOnline 
    -UserPrincipalName admin-account@your-domain.onmicrosoft.com

Get-ServicePrincipal
Get-MailboxPermission 
    -Identity "AdeleV@your-domain.onmicrosoft.com"

Replace "AdeleV@your-domain.onmicrosoft.com" with your mailbox email.

If you are missing permissions, add them using PowerShell as described here:
https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp

ago by (303k points)
...