Get IMAP Mail Messages Login Error

Hi all,

during conversion Windows Legacy projects into Windows (compatible with .Net6) I run into a problem with getting a list of Emails, from company’s Outlook mailbox.

This is a browser version of an Outlook:

Previously (.Net 4) I was using an activity: “Get Exchange Mail Messages” and it worked perfectly, but since it’s not available anymore in new projects, I had to replace it with something else, so I try with “Get IMAP Mail Messages” activity, but still with no luck:
image

I’m getting an error: “Login Failed”, but I know that credentails, that I use are correct, also I’ve read on the forum the error is pretty generic and could be connected with other things, such as security settings, IP allowance-permision, SSL connection and more.

Below are details for the activity that I use:

Our IT claims the IMAP service is on for the target mailbox. I have a feeling, that the problem is somehow connected with SSL settings - with previously used activity (“Exchange”), there was no SSL settings to be set and everything was working - please help.
Regards, Peter.

@Piotr_Gajewski

Please run in debug mode and open the exception details from the locals panel…that might give more info on what is going wrong…

Try setting ssl to auto…let it pick and check if that solves

Cheers

Hi @Piotr_Gajewski

This might be helpful for you.

Cheers,

This is what I get when running in debug:

MailKit.Security.AuthenticationException: LOGIN failed. at MailKit.Net.Imap.ImapClient.d__103.MoveNext() in D:\src\MailKit\MailKit\Net\Imap\ImapClient.cs:line 1250
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MailKit.Net.Imap.ImapClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken) in D:\src\MailKit\MailKit\Net\Imap\ImapClient.cs:line 1320
at MailKit.MailService.Authenticate(ICredentials credentials, CancellationToken cancellationToken) in D:\src\MailKit\MailKit\MailService.cs:line 1237
at UiPath.Mail.UiPMailKit.Extensions.IMailServiceExtensions.Authenticate(IMailService service, UserSettings userSettings, CancellationToken cancellationToken)
at UiPath.Mail.MailServiceFactory.CreateMailKitService(EmailProtocol protocol, String server, Int32 port, UserSettings userSettings, SecureSocketOptions options, Int32 timeout, CancellationToken cancellationToken)
at UiPath.Mail.MimeMailService.GetIMAPMessages(UserSettings userSettings, ServerSettings serverSettings, Int32 top, String mailfolder, String filterExpression, String charset, EOrderByDate orderByDate, SecureSocketEncryption SecureConnection, Boolean deleteMessages, Boolean onlyUnreadMessages, Boolean markAsRead, Action1 logAction, CancellationToken cancellationToken) at UiPath.Mail.IMAP.Activities.GetIMAPMailMessages.<>c__DisplayClass76_0.<GetMessages>b__0() at System.Threading.Tasks.Task1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Mail.Activities.Extensions.TaskExtensions.d__1`1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Mail.Activities.GetMailActivity.d__13.MoveNext()
— End of stack trace from previous location where exception was thrown —
at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

@Piotr_Gajewski

Can you try changing the mail activity version and check if it solves…does not look purely authentication issue…and i see a no reply mail box…that you are using…does that have any restrictions?

Cheers

Hi @Piotr_Gajewski

I would strongly recommend using a different type of authentication since Microsoft is deprecating basic authentication this month. Instead, you may use “Get Outlook Messages” that connects using the current outlook profile on the machine, no authentication needed as it goes through whatever settings you have setup.

Also, you may also consider using the O365 activities scope.

Get Outlook Mail Messages (uipath.com)

Configuring the Azure AD for Outlook 365 Automation (uipath.com)

Deprecation of Basic authentication in Exchange Online | Microsoft Learn

I tried to downgrade UiPath Mails dependency but it didn’t help.

Using “Get Outlook Mail Messages” activity gave me the emails list that I wanted, but as I understand, it needs the Outlook application to be installed on the machine, where I want to run a Robot?

Is there any way to manipulate the Emails without having Outlook installed first?

@Piotr_Gajewski

If you have an a ure setup you can try using office 365 activities

Or you have integration services on orchestrator which cna be enabled and connect your office 365 emails

Also try with encryption ssl/tls

Cheers

Cheers

Thank you all for your support and help! After trying mentioned above methods, I’ve found out some replacements for IMAP or Exchange activities, which I would like to share with others in similar situation:

Possible solutions (.Net6):

  1. Microsoft Office 365 Scope + Get Mail activity.
    UiPath needs to be registered on https://portal.azure.com/ + proper Mail read/write permissions need to be added.
  2. Use Outlook 365 + For Each Email activity.
    Need to login to target mailbox account (as I understad, this could be done also via Orchestrator\Integration Service by adding a connection there).
  3. Get Outlook Mail Messages activity.
    Outlook application needs to be installed and configured on target desktop, where Robot is running.

I will recreate old (Legacy) projects and try to go with option 1 or 2, best regards.
Peter

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.