Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Find email-enabled public folders exclusively using "Microsoft.Office.Interop.Outlook"

Find email-enabled public folders exclusively using "Microsoft.Office.Interop.Outlook"

Scheduled Pinned Locked Moved C#
databasecomwindows-adminhelpquestion
1 Posts 1 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    temuco
    wrote on last edited by
    #1

    Is there a way to exclusively identify email-enabled public folders using Microsoft.Office.Interop.Outlook? EWS or PowerShell should not be used. The program should run on the workstation and utilize the installed Outlook. Once I've found an email-enabled public folder, I should list the emails contained within it. So far, I'm encountering difficulties. For instance, I have the following method:

    // Recursive method for listing the email addresses of email-enabled public folders
    static void ListPublicFolders(Outlook.Folder? folder, string indent)
    {
    if (folder != null)
    {
    foreach (object obj in folder.Folders)
    {
    if (obj is Outlook.Folder)
    {
    Outlook.Folder? subFolder = obj as Outlook.Folder;

                if (subFolder != null && subFolder.DefaultItemType == Outlook.OlItemType.olMailItem)
                {
                    Outlook.MAPIFolder? parentFolder = subFolder.Parent as Outlook.MAPIFolder;
                    string              parentName   = parentFolder != null ? parentFolder.Name : "Parent folder not found";
    
                    Console.WriteLine($"{indent}- {subFolder.Name}: {parentName}");
    
                    if (parentFolder != null)
                    {
                        Marshal.ReleaseComObject(parentFolder);
                    }
                }
    
                ListPublicFolders(subFolder, indent + "  ");
    
                if (subFolder != null)
                {
                    Marshal.ReleaseComObject(subFolder);
                }
            }
        }
    }
    

    }

    The query

    if (subFolder != null && subFolder.DefaultItemType == Outlook.OlItemType.olMailItem)

    fails because subFolder.DefaultItemType returns the value Outlook.OlItemType.olPostItem, even though the public folder was set up as an email-enabled folder in Exchange. Specifically, this is in Microsoft 365. In the Exchange admin center, when creating the folder, I explicitly checked the box for "Email-enabled." This action resulted in two additional options: "Delegation" and "Email properties." In "Email properties," I can specify an alias and a display name. By default, both fields are set to "Orders." Now, I expect the public folder to be email-enabled, with the email address orders@domain.tld. I don't understand why Outlook is treating the folder incorrectly (I can only create posts and not send emails). Perhaps someone can help me figure this out. Thank you and

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups