
Announcements
I am trying to connect to an Office 365 mail account and fetch emails using Power Automate Desktop. I receive the error below even though the credentials I supply are correct
Microsoft.Flow.RPA.Desktop.Modules.SDK.ActionException: Authentication failed on IMAP server outlook.office365.com. ---> MailKit.Security.AuthenticationException: LOGIN failed.
at MailKit.Net.Imap.ImapClient.<AuthenticateAsync>d__83.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MailKit.Net.Imap.ImapClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken)
at MailKit.MailService.Authenticate(Encoding encoding, String userName, String password, CancellationToken cancellationToken)
at Microsoft.Flow.RPA.Desktop.Modules.Email.Actions.EmailActions.RetrieveEmails(Variant imapServer, Variant username, Variant varPassword, Variant mailFolder, Variant fromContains, Variant toContains, Variant subjectContains, Variant bodyContains, Variant sentSince, Variant sentUpTo, Variant saveAttachmentsInto, Variant& retrievedEmails, Int32 serverPort, Boolean enableSsl, Int32 retrieveOnlyUnread, Boolean saveAttachments, Boolean markAsRead, Boolean acceptUntrustedCertificates)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.Email.Actions.RetrieveEmails.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)
I don't believe office 365 supports IMAP by default it uses Exchange protocol(kinda) I've run into this before not with Power Automate but with legacy email migrations. Check this out -https://learn.microsoft.com/en-us/exchange/troubleshoot/administration/cannot-connect-mailbox-pop-imap-outlook. I wouldn't recommend using basic authentication for o365 and figuring out if exchange protocol is supported in Power Automate Desktop(or doing it all in a cloud flow thats what I've done when connecting to o365 emails). If you can use PAD to send back the information you need to a cloud flow then do all the email work on the cloud side(which may not work in your usecase). I can try to test this too but I've run into issues with this before but that is because we use a third party 2fa application that blocks those types of authentication.