Get Outlook Mail Messages: The specified folder does not exist: UNATTENDED BOT

Hello, I have developed and have been running a series of three unattended bots on servers. While running the workflows for the unattended bots, there is a sequence responsible for getting Outlook messages in a subfolder within Outlook using the “Get Outlook Mail Messages” activity. The process loops and checks the folder once every few minutes in addition to several other subfolders within the Outlook account. Over my last few runs, this sequence will execute flawlessly as it loops, however, there does not seem to be a pattern that I can see, but the bot will randomly throw the “Get Outlook Mail Messages: The specified folder does not exist” error even though it had been successful time and time again within the workflow loop.

I have read other posts on this error that suggest various fixes, but none have seemed to work for me. I am curious if this could be related to a timeout issue for the activity?

I will be glad to provide as much information as I can, any and all help is greatly appreciated.

Thank you!

EDIT 1: Added GEH to the workflow, when the error occurs, this is the info listed

  • The operation has timed out.

RemoteException wrapping System.TimeoutException: The operation has timed out.
at UiPath.Mail.Activities.GetMailActivity.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)
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at UiPath.Executor.BaseRunner.EndExecute(IAsyncResult result)
at UiPath.Executor.InProcessRunner.EndExecute(IAsyncResult result)
at UiPath.Core.Activities.ExecutorInvokeActivity.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)

This description suggests a timeout error. I have adjusted the delay values in the “Get Outlook Mail” activity with no change to the error.

EDIT2: I have tried troubleshooting this issue for the last few days now, still intermittently receiving the System.TimeoutException error. I believe the issue may be at the VM level where Outlook is installed.

Follow up question: If Outlook is installed on a VM and on a workstation and both are logged in as the same Outlook account, Outlook obviously has to be closed on the VM in order for an Outlook workflow to be executed on the VM. Could it also be true that the Outlook workflow can not run on the VM if Outlook is also open on another workstation?

Hey @sean.finn

I hope you are well.

What have you tried thus far?

A few things I’ve noticed:

  • Outlook needs to be open when you are using trying to access the mailbox
  • The folder you are trying to read needs to be focused on else a timeout sometimes occurs
  • In a case where a folder is no longer found, try the following:
  1. Force the folder name to be string by using .ToString
  2. Ensure that your folder is on the same level as Inbox, Outbox, Sent items, etc. Sometimes subfolders cause issues as well

Please let me know if you have any other questions! Please mark this as the solution if it helps you solve your problem

Have a great one further!
Kind regards,
Jacqui

Thanks for the suggestions, at this point, I have tried updating my UiPath.Mail.Activities package in Studio, enabled/disabled Programmatic Access in Outlook, tried running Outlook as admin, all with failed results. I have also tried removing the account name in the account properties for the “Get Outlook Mail Message” activity since there is only one account associated with the Outlook app.

It was my understanding that Outlook would be able to run on a VM with an unattended bot, so would you be able to expand on your point that Outlook needs to be open when accessing the mailbox?

The folder I am searching in Outlook is specified in the properties of the “Get Outlook Mail Message” activity as well.

I will try the two fixes you have specified, however, the folders are already on the same level.

Thanks,
Sean

1 Like

Hey @sean.finn

Great, keen to know how it turns out.

You are correct, a VM can be used to run the unattended bot. Even though the bot runs in an unattended fashion, it still interfaces with the processes\ programs that the human would typically use. Thus, Outlook can still be used by an unattended bot but my suggestion would be to check that Outlook is already running (if it isn’t, then start it) before continuing the process.

What we do in our environments is ensure that all common processes (Excel, Outlook, SAP, browsers, etc.) are closed before we start process execution. We implement a “Kill All” sequence before we initialise any processes (like Outlook) that we need. Once the processes as executed, we reference the “Kill All” sequence again.

Please let me know if there are any more questions!

Have a great one further!

Thus, Outlook can still be used by an unattended bot but my suggestion would be to check that Outlook is already running (if it isn’t, then start it) before continuing the process.

Is this not what happens automatically with the “Get Outlook Mail Message” activity or are you suggesting adding an “Open Application” activity to open and initialize Outlook to read messages?

I have not had this problem in the past or while running on my development machine and have been able to scrape emails with just the “Get Outlook Mail Message” activity.

I have added a “Kill Process” activity before one of the “Get Outlook Mail Message” activities with no result either.

Force the folder name to be string by using .ToString

Even if the folder name is already in a string format, are you suggesting using “Folder Name”.tostring?

Point 1:
No not quite. So “Get Outlook Mail Message” essentially attaches to Outlook, it doesn’t instantiate Outlook, so you may want an “Open Application” before the “Get Outlook Mail Message” activity.

Point 2:
Yep. That’s exactly what I am suggesting. I know it is bizarre. I also couldn’t believe it when I read about it on the forum, however, “Inbox”.ToString actually worked:

Are you by any chance using Azure Active Directory? Another option would be to try the Microsoft Office 365 activity instead.

Negative, we are utilizing Outlook 2016 desktop, no AAD at this point. I actually used these activities in development and determined they did not work for my needs.

1 Like

I have just added the “inbox”.tostring suggestion, running now to see if the timeout will occur. will add an “Open Application” next if the issue is still present

1 Like

I just wanted to mention that this documentation of the Outlook email automation activities specify that “it is not necessary to have the application open.” I will attempt again with Start Process/Open Application anyway if the .tostring fix does not work.

Yeah, I did read that as well. It does, however, state that you would need to be logged into Outlook. That caused issues for us when the application was closed. The simple fix for us was ensuring a kill-start approach was followed until we moved over to the M365 library.

Correct, currently the Outlook account is logged in on the VM so that is not the issue. .tostring has been working for the past hour straight, hoping that this actually fixes the problem!

1 Like