cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jaleefpk
Helper III
Helper III

Moving Emails to Subfolder in round Robin style

Capture.JPGHi All,

 

i have a shared mailbox in which i am running the below script to move the incoming messages to subfolder in round robin style.can we achive this using microsoft flow ? or any other way to automate it in background,

thanks ,

 

Dim i As Long
Private WithEvents olInboxItems As Items
 
Private Sub Application_Startup()
  Dim objNS As NameSpace
  Set objNS = Application.Session
  Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)

    Dim objDestFolder As Outlook.MAPIFolder
    Dim moveFolder As String
   
    If Item.Class = olMail Then
    
    Select Case i
     Case 0
          moveFolder = "Folder01"
     Case 1
          moveFolder = "Folder02"
     Case 2
          moveFolder = "Folder03"
     Case 3
          moveFolder = "Folder04"
     Case 4
          moveFolder = "Folder05"
    End Select
   
Set objDestFolder = Session.GetDefaultFolder(olFolderInbox).Folders(moveFolder)
  Item.move objDestFolder
        End If
       
        Err.Clear
         
     i = i + 1
     Debug.Print i
     If i = 5 Then i = 0
 Set objDestFolder = Nothing
 End Sub

 

 

5 REPLIES 5
v-yamao-msft
Community Support
Community Support

Hi @jaleefpk,

 

By using Round-robin style, do you mean that you want to choose all elements in a group, usually from the top to the bottom of a list and then starting again at the top of the list and so on?

There is no direct way could be used to achieve it, while if you are familiar with Custom API, please try integrating Custom APIs with flow. The following docs for your reference:

https://docs.microsoft.com/en-us/flow/developer/register-custom-api

By the way, we could also consider using Switch cases if you don’t have too many folders.

A simple flow likes below for your reference.

1.PNG

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yamao-msft ,

 

we have centralized mailbox in which we receive emails from cutomer ,and i have  7 agents to check emails and enter order to our ERP.

i want to distribute the incoming emails regardless of sender or subject to agents equally .

 

Hi @jaleefpk,

 

Thanks for updating.

It seems that you would like to dispatch the incoming emails to 7 agents regardless of send or subject equally.

I am afraid that it could not be achieved by using OOB flow actions directly.

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have done it using flow using the received time.but distribtion to folders are not equal.

Please let me know if you guys find any option to achieve that

I like this workaround! I also have the same usecase - creating a round-robin distribution - and would like to achieve it through flow. Please let us know if you create a way to do it. 

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Users online (1,567)