I'm creating a macro for Outlook that processes email items in designated folder that gets triggered by a rule. My Sub routine sets the sub-folder like this:
Set olSub = olMailbox.Folders("Customer").Folders("Requests").Folders("Open")
I would like to be able to use my Sub for many different folders, the only difference being the line above.
My question is how can I pass an array to my Sub that would set olSub with the chained .Folders() statement? Keeping in mind the number of sub-folders and therefore the array could vary in length.
The desired outcome would be something like this:
Sub MainRoutine(olArr)
...
' Some sort of magic loop that sets olSub from olArr until,
olSub = olMailbox.Folders("Customer").Folders("Requests").Folders("Open")
...
End Sub
Sub OtherRoutine()
olArr = Array("Customer", "Requests", "Open")
MainRoutine olArr
End Sub