How to access "Inbox" subfolders with "Get outlook mail message"

Hello,

  1. Use Invoke Code activity, click on Edit code and Copy paste the below given code.

Dim olApp As Microsoft.Office.Interop.Outlook.Application
Dim olNs As Microsoft.Office.Interop.Outlook.Namespace
Dim olParentFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim olFolderA As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim olFolderB As Microsoft.Office.Interop.Outlook.MAPIFolder
olApp = New Microsoft.Office.Interop.Outlook.Application
olNs = olApp.GetNamespace(“MAPI”)
olParentFolder = olNs.Folders(“YourEmail@outlook.com ”).Folders(“Inbox”)
For Each olFolderA In olParentFolder.Folders
Console.WriteLine(olFolderA.FolderPath)
OutlookFolderNames.Add(olFolderA.FolderPath)
Next

In the Place of YourEmail@outlook.com put your Email Id from which you wanted to retrieve mail Items.
Click on Edit Arguments and : Pass a List(Of String) OutlookFolderNames Variable to hold the value of Subfolder Paths

Refer the below Screenshots for more details :
image

Now you have all the Subfolder Paths in a List Variable

  1. Use for each loop and loop over this List,
    In for each use get outlook mail message activity pass the loop item to MailFolder property of get outlook mail message activity
    You will get mail items from required subfolder, you can perform your business logic on it.
    Later the for loop will continue with next Subfolder path and its mail messages

image

Regards,
Rohith

2 Likes