office365outlook-addinoutlook-redemption

Using Outlook Redemption, How do I get a list of Shared Calendars?


We're using:

Redemption 6.3
Windows 11
Office 365
Outlook Version 2307 Build 16626.2022

What I would like to do is retrieve the list of calendars listed under the Shared Calendars group.

This code only returned a couple of publicly shared folders that aren't in the "Shared Folders" group pictured below.

    RDOFolder calendar = rdoSession.GetSharedDefaultFolder("--mailbox name--", rdoDefaultFolders.olFolderCalendar);
    foreach( RDOFolder folder in calendar.Folders )
    {
        System.Diagnostics.Debug.WriteLine(folder.Name);
    }


USING "OutlookSpy" I can find what I'm looking for in the NavigationPane, but this is likely not how I'll need to get to the information I want using Redemption.

enter image description here

HERE IS WHAT I WAS ABLE TO DO WITH INTEROP. IT WORKS, BUT NOT SURE IF IT WOULD HAVE BEEN EASIER WITH REDMEPTION

    private static IEnumerable<string> ListSharedCalendars()
    {

        Outlook.Folder myCalendar = null;
        Outlook.Explorers myExplorers = null;
        Outlook.Explorer myCalendarExplorer = null;
        Outlook.CalendarModule calendarModule = null;
        Outlook.NavigationGroups navGroups = null;
        Outlook.NavigationFolders myNavigationFolders = null;
        Outlook.NavigationPane myNavigationPane = null;
        Outlook.NavigationModules myNavigationModules = null;

        List<string> calendarList = new List<string>();
        

        try
        {
            application = new Outlook.Application();
            nameSpace = application.GetNamespace("MAPI");

            myCalendar = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;

            myExplorers = application.Explorers;
            myCalendarExplorer = myExplorers.Add(myCalendar, Outlook.OlFolderDisplayMode.olFolderDisplayNormal);



            if (myExplorers.Count > 0)
            {
                try
                {
                    myNavigationPane = myCalendarExplorer.NavigationPane;
                    myNavigationModules = myNavigationPane.Modules;

                    calendarModule = myNavigationModules["Calendar"] as Outlook.CalendarModule;
                    navGroups = calendarModule.NavigationGroups;

                    int groupCount = navGroups.Count;

                    try
                    {
                        for (int x = 1; x <= groupCount; x++)
                        {
                            try
                            {
                                calendarList.Add(navGroups[x].Name);
                                myNavigationFolders = navGroups[x].NavigationFolders;

                                int navfolderCount = myNavigationFolders.Count;
                                for (int y = 1; y <= navfolderCount; y++)
                                {
                                    calendarList.Add("\t-" + myNavigationFolders[y].DisplayName);
                                }
                            }
                            catch (System.Exception ex)
                            {
                                System.Diagnostics.Debug.WriteLine(ex);
                            }
                            finally
                            {
                                if (myNavigationFolders != null) { Marshal.ReleaseComObject(myNavigationFolders); myNavigationFolders = null; }
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex);
                    }
                    finally
                    {
                        if (navGroups != null) { Marshal.ReleaseComObject(navGroups); navGroups = null; }
                    }
                }
                catch (System.Exception otlEx)
                {
                    System.Diagnostics.Debug.WriteLine(otlEx);
                }
                finally
                {
                    if (navGroups != null) { Marshal.ReleaseComObject(navGroups); navGroups = null; }
                    if (calendarModule != null) { Marshal.ReleaseComObject(calendarModule); calendarModule = null; }
                    if (myNavigationModules != null) { Marshal.ReleaseComObject(myNavigationModules); myNavigationModules = null; }
                    if (myNavigationPane != null) { Marshal.ReleaseComObject(myNavigationPane); myNavigationPane = null; }


                }
            }


        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex);
        }
        finally
        {
            if (myExplorers != null) { Marshal.ReleaseComObject(myExplorers); myExplorers = null; }
            if (myCalendarExplorer != null) { Marshal.ReleaseComObject(myCalendarExplorer); myCalendarExplorer = null; }
            if (calendarModule != null) { Marshal.ReleaseComObject(calendarModule); calendarModule = null; }
            if (navGroups != null) { Marshal.ReleaseComObject(navGroups); navGroups = null; }
            if (myNavigationFolders != null) { Marshal.ReleaseComObject(myNavigationFolders); myNavigationFolders = null; }
            if (myNavigationPane != null) { Marshal.ReleaseComObject(myNavigationPane); myNavigationPane = null; }
            if (myNavigationModules != null) { Marshal.ReleaseComObject(myNavigationModules); myNavigationModules = null; }
            if (myCalendar != null) { Marshal.ReleaseComObject(myCalendar); myCalendar = null; }


            nameSpace.Logoff();
            

            if (nameSpace != null) { Marshal.ReleaseComObject(nameSpace); nameSpace = null; }
            if (application != null) { Marshal.ReleaseComObject(application); application = null; }
        }

        return calendarList;
    }

Solution

  • AS far as I know, it is stored in the Outlook favorites, accessible though RDOSession.Favorites. The type (RDOFavorite.FolderType) is fftCalendar (2).