Getting Or Moving An Outlook Mail Message Fails With Error The Specified Folder Does Not Exist

While trying to get Outlook mails from a shared mailbox, the job fails with "The specified folder does not exist", even though the folder and the shared mailbox are added in Outlook. Robot can not move emails from a generic mailbox in Outlook, because it gets the error that "The specified folder does not exist".

Notice: This behavior was fixed with the release of the Mail.Activities package version 1.21.2. Upgrade the Mail.Activities package to this version of higher to fix the issue of "The specified folder does not exist".

The activities "Get Outlook mail message" and "Move Outlook mail message" have a property called "Account", that allows the usage of a shared (generic) mailbox.

A requirement of using a shared mailbox in the Account property is to have it added in Outlook. For info on how to add that, see Open and Use A Shared Mailbox in Outlook

If the value for the Account property does not match the display name of the shared/generic mailbox in Outlook, it throws the error "The specified folder does not exist".- even though the folder exists in the Outlook app.

getOutlookMail_error.png

Depending on the Office version, the display name of a generic mailbox (i.e, as a human sees it in Outlook after the mailbox is added) can be the full email address, like genericmailbox@domain.com or a user-friendly name, like Generic Mailbox.

In order to solve the error "The specified folder does not exist", make sure to add in the "Account" property the display name of the generic/shared mailbox.

For further information, read the documentation for Get Outlook Mail Message and Move Outlook Mail Message.

If the above approach did not help, proceed as per below:

  1. Enable the Robot Diagnostic logs and gather the event viewer logs
    1. Enable the Robot Diagnostic logs
    2. Run the automation again
    3. Gather the application event viewer logs. (Event Viewer->Windows Logs->Application)
    4. The event viewer logs should contain a warning that most likely explains the issue.
  2. If slashes are used in the Folder field of the activity, make sure they are back slashes (i.e. “Inbox\Test”)
  3. If you have the generic mailbox added in Outlook, navigate though the folder structure and make sure that you have access to see the emails and their contents. If it's not possible, engage your IT teams for assistance.
  4. Try running the following powershell commands. These are similar to the steps UiPath takes and can help determine if this is a configuration issue. Note, all these commands need to be run in sequential order:
    1. Creates in outlook object that has access to the needed mailbox.
    2. Add-Type -AssemblyName Microsoft.Office.Interop.Outlook
    3. $outlook = New-Object -ComObject Outlook.Application
    4. $namespace = $outlook.GetNamespace('MAPI')
  5. The above command should not fail, so if it does, system libraries or powershell dependencies may be missing. Fix that issue before continuing.
  6. Verify that the Robot can “see” the mail account with the following powershell command. The mailbox name would be the mailbox's email address.
    • $account = $namespace.Folders.Item('')
  7. If the above command errors out, it means the problem is not with UiPath. It could be a typo, or it could possible be that security policies are blocking applications from interacting with Outlook.
    1. Make sure that the specific folder in question is visible. For example, to see the folder “Inbox”, run the following powershell command
      • $account.Folders.Item('Inbox').Name
    2. If the folder being accessed was “Inbox/Test”, then the following command would be used
      • $account.Folders.Item('Inbox').Folders.Item(“Test”).Name
    3. The pattern continues for any subsequent folders. If the above commands fail, it means that Applications are being blocked from seeing the folders being accessed. Doublecheck folder permissions and contact your IT team.
  8. If all of the above powershell commands succeed, open a ticket with UiPath Support so that it can be investigated further.