none
Microsoft.Office.Interop.Outlook.NavigationFolder folder --> Exception thrown: 'System.Runtime.InteropServices.COMException RRS feed

  • Question

  • Hi

    I am trying to get all the currently select calendar folders from Outlook Navigation pane, after getting the calendar folders i will extract all calendar appointment from the selected folders.

    I am using this code to get the selected folders:

     Microsoft.Office.Interop.Outlook._Application Appss = new Microsoft.Office.Interop.Outlook.Application();
                            Microsoft.Office.Interop.Outlook.CalendarModule calModule = (Microsoft.Office.Interop.Outlook.CalendarModule)Appss.ActiveExplorer().NavigationPane.Modules.GetNavigationModule(Microsoft.Office.Interop.Outlook.OlNavigationModuleType.olModuleCalendar);
                            foreach (Microsoft.Office.Interop.Outlook.NavigationGroup group in calModule.NavigationGroups)
                            {
                                foreach (Microsoft.Office.Interop.Outlook.NavigationFolder folder in group.NavigationFolders)
                                {
                                    if (folder.IsSelected == true)
                                    {
                                        try
                                        {
                                         Microsoft.Office.Interop.Outlook.Folder ff = folder.Folder as Microsoft.Office.Interop.Outlook.Folder;
                                        }
                                        catch
                                        {
                                            new MessageBoxForm
                                            {
                                                Message = "Shared folder " + folder.DisplayName + " has low permission, cant get appointments for this folder"
                                            }.ShowMessageDialog(appWindow.NativeWindow);
                                            return;
                                        }
                                    }
                                }
                            }

    This code work for all calendars were I have "Full Details" permission.

    When i choose a shared calendar with only free/busy permission the program crash with this error Exception thrown: 'System.Runtime.InteropServices.COMException and this message:

    But if i try to get the same shared folder with only free/busy permission this way:

    var folder1 = Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder;

    then it works, but I want to get all the selected folders from the navigation pane with the first code example.

    Any idea about how I can solve this issue?

    





    • Edited by HenrikSA Sunday, May 14, 2017 5:13 PM
    Friday, May 12, 2017 11:54 AM

All replies

  • Hi HenrikSA,

    I try to test your code on my side with "Free/ Busy" permission. it did not gave me any error with both statements.

      private void button1_Click(object sender, EventArgs e)
            {
                Microsoft.Office.Interop.Outlook._Application Appss = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.CalendarModule calModule = (Microsoft.Office.Interop.Outlook.CalendarModule)Appss.ActiveExplorer().NavigationPane.Modules.GetNavigationModule(Microsoft.Office.Interop.Outlook.OlNavigationModuleType.olModuleCalendar);
                foreach (Microsoft.Office.Interop.Outlook.NavigationGroup group in calModule.NavigationGroups)
                {
                    foreach (Microsoft.Office.Interop.Outlook.NavigationFolder folder in group.NavigationFolders)
                    {
                        if (folder.IsSelected == true)
                        {
                            try
                            {
                                Microsoft.Office.Interop.Outlook.Folder ff = folder.Folder as Microsoft.Office.Interop.Outlook.Folder;
                                var folder1 = Appss.ActiveExplorer().CurrentFolder;
                                
                            }
                            catch
                            {
                                //new MessageBoxForm
                                //{
                                //    Message = "Shared folder " + folder.DisplayName + " has low permission, cant get appointments for this folder"
                                //}.ShowMessageDialog(appWindow.NativeWindow);
                                return;
                            }
                        }
                    }
                }
            }

    please try to test the same code on other machine to check whether issue is related with particular machine or not.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 16, 2017 7:22 AM
    Moderator
  • Hi Deepak

    You didn´t hit the catch() block?

    Are you sure you are trying to open a shared folder with only free/busy time, subject, location access?

    if you try to open an appointment in a shared folder with free/busy time, subject, location access  directly in Outlook, you should get the following popup from Outlook:


    • Edited by HenrikSA Tuesday, May 16, 2017 7:40 AM
    Tuesday, May 16, 2017 7:40 AM