Support > Forums > OpenBots Studio > How does one step through all Mailbox folders?
This is what currently happens:
Required:
A report to enable the manager of the department to assess if something is being overlooked or is taking too long to resolve.
The automated task:
Step 1 - Step through all folders except the "Completed" folder. Step 2 - For each email in the above folders, store selected information in a Data Table for analysis.
I am not sure how to achieve Step 1. Could you please assist.
Regards Mike
This forum has 317 topics, 687 replies, and was last updated 4 months ago by Nataly Alvarado...
Hi Mike Hirshowitz,
Thanks for submitting your support query.
Please note that currently Studio does not have a command that generates the list of existing folder names in your email account dynamically. If getting the list of folder names as a static value is not an option, then we can use custom C# code to retrieve the values.
One of the advantages with OpenBots Studio, is that users are able to invoke C# code directly with any OpenBots script. Thus, giving the user access to the extensive list of C# libraries available.
In this case, we can use the Microsoft.Office.Interop.Outlook to obtain the folder names.
Import the Microsoft.Office.Interop.Outlook library to your script.
Define a List of string variable, this variable will hold the folder names generated, so we can use it as input for other Outlook commands
Use the Evaluate Snippet command to run the snipped of C# code. Depending on the use case and requirements, the snippet may vary. In this case, I am returning the list of folders in the root Outlook account. This code can be modified to return the list of folders within a subfolder, or the list of all folders + subfolders, etc.
var vOutlookApp = new Microsoft.Office.Interop.Outlook.Application();
var vNameSpace = vOutlookApp.GetNamespace("MAPI");
var folder = vNameSpace.Folders["nataly.alvarado@OpenBots.AI"];
vFolderNames = new List
foreach (Microsoft.Office.Interop.Outlook.Folder subFolder in folder.Folders) { vFolderNames.Add(subFolder.Name);
}
Now the vFolderNames variable contains the list of folder names extracted. So, we can use the values in the list as input for the Get Outlook Emails command.
**Note that I will raise this as a suggestion to the product team, so a Get Outlook Folders command can be added for future Studio releases.
Please let me know if you have any questions.
You are not authorized to reply, please click here to login and add your reply to this topic.