Outlook mail messages distribution from inbox to subfolders

Please find below requirement to build workflow.

  1. Read all mails from inbox in outlook.
  2. move mails from inbox to subfolder(there are 5 subfolders under inbox for example).
  3. For each mail after moving to subfolder the excel file should get update with assigned count for the specific sub folder.
    4.As mentioned above all mails from inbox should move to all subfolders equally(if inbox has 16 mails first subfolder should get 6 and remaining 4 folders should get 5 and for next assignment should start from second subfolder as first subfolder already have 1 extra)
  4. condition is the subfolder with less count should get assigned first.
  5. initially all subfolders are empty.

Please let me know if you need more information.

I am waiting for your kind response.

This is the second topic you have created @Suresh_Kappa, but I dont find any answers for that topic :slight_smile:

For your requirement,

  1. read the mails and get the count
  2. Use while condition to loop through all the mails and provide the condition as the count you got above
  3. Inside that, use switch statement to move the first loop to first sub folder, second mail to second sub folder and so on, (for this initialize a variable with a value 1, and increment it everytime to help you out in the switch case.) When the loop comes to fifth sub folder, assign the variable with value 1 again so that for next loop, it will move the mail to first sub folder

Hi Hareesh,

Thank You for your response.

If possible will you please build the flow and share me please.

looking for your kind response.

I’m missing a condition there which is, assign the lowest count sub folder first. I’m just trying to find a new way for that, I will post if I did that, as I have mentioned very easy steps above, please try to build on your own @Suresh_Kappa

Hi Hareesh,

Thank You so much I will try to build the flow as you mentioned.

We hope the code provided in this chat helped you or please let us know if you face any challenges.

Hi HariHaraMurugan,

Still this is not fulfilled sorry about that.

The problem is always it is moving first mail to first subfolder under inbox.
if it can read subfolder count and identify the subfolder with least count and move the mail first then my problem will get resolve.

Hi Suresh,

Kindly try the below options and let me know if it works for your requirement with the same code.

Create 3 folders (A,B,C) under Inbox.
Keep the count of mails in folder A=3, B=2, C=3 and have one unread mail in Inbox. Then run the bot, it will move the mail to B folder only.

Logic written to distribute the Inbox mails equally to all the sub folders whenever you run the bot. Please correct if your requirement is different from the above.

Hi HariHaraMurugan,

If possible will you please share the workflow.

OutlookMailDistribution.zip (9.2 KB)

Thank You so much HariHaraMurugan…

What if we put incorrect subfolder name, how does Ui Path will throw an error?

Why don’t you try that on your own @NimitBabel giving a wrong folder name?

Anyway,It will give the error like, folder does not exists :slight_smile:

I tried it with Outlook 2010 but it is not throwing an error.