You need to look at MailItem.Parent and pass it to Outlook.Folder . When you have a Folder , you can access the display name using Folder.Name . If you want to determine if the selected item is an Inbox subfolder, you will need to recursively call the Parent tree until Parent is null to find the root parent folder.
Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer(); Outlook.MailItem mailItem = explorer.Selection.OfType<Outlook.MailItem>().First(); Outlook.Folder parentFolder = mailItem.Parent as Outlook.Folder; if (parentFolder.Parent == null)
Obviously, you should add error handling and object removal to this code sample.
source share