none
Hiding Reading Pane not working in Outlook 2010 addin RRS feed

  • Question

  • Hi,

    I have created an outlook 2010 shared addin using VS 2010 where I have to disable reading pane (preview pane). Code i have used is :

     private void HidePanels()
            {           
                Outlook.NavigationPane navigationPane = null;
                Outlook.Explorer currExplorer = null;
                Outlook.Application app = new Outlook.Application();
                Boolean boo = true;
    
                try
                {
                  //  currExplorer = ((Outlook.Application)applicationObject).ActiveExplorer();
                    currExplorer = app.ActiveExplorer();
                        
                    boo = currExplorer.IsPaneVisible(Outlook.OlPane.olPreview);
                    currExplorer.ShowPane(Outlook.OlPane.olPreview, false);
                    currExplorer.ShowPane(Outlook.OlPane.olToDoBar, true);
    
                    navigationPane = ((Outlook.Application)applicationObject).ActiveExplorer().NavigationPane;
                    navigationPane.IsCollapsed = true;
                }
                catch (Exception ex)
                {
                    //  MessageBox.Show("Error:"+ex);
                }
                finally
                {
                    if (navigationPane != null)
                        Marshal.ReleaseComObject(navigationPane);
                    if (currExplorer != null)
                        Marshal.ReleaseComObject(currExplorer);
                }
            }

    Here hiding Navigation pane and todo bar is working fine but i am not able to hide reading pane.

    boo always returns false and setting olPreview true or false doesn't make any difference. What am I doing wrong?


    • Edited by BivekNiraula Monday, March 3, 2014 6:33 AM mistake in description
    Monday, March 3, 2014 6:28 AM

Answers

  • Hello Bivek,

    Your code looks good, I don't see anything strange in the code except new Outlook application. The ShowPane method of the Explorer class is used for displaying or hiding a specific pane in the explorer. 

    Anyway, I have just tested your code in one of my virtual machines with Outlook 2010 installed. It works as expected, I didn't notice anything strange on my road. So, please make sure that you have no other add-ins installed that can affect to the reading pane. Also please make sure that you have all the latest updates and service packs installed for Office/Outlook 2010 (SP2).


    Monday, March 3, 2014 12:38 PM
  • Hi

    Your code with slight tweaking will work perfectly fine.

    Here is the modified code. I tried it with Outlook 2010 and called the HidePanels() method from the ThisAddIn_Startup event. 

    private void HidePanels()
            {
                Outlook.NavigationPane navigationPane = null;
                Outlook.Explorer currExplorer = null;
                //Outlook.Application app = new Outlook.Application();
                Boolean boo = true;
    
                try
                {
                    //currExplorer = ((Outlook.Application)applicationObject).ActiveExplorer();
                    //currExplorer = app.ActiveExplorer();
                    //Here this keyword represents the current add-in, i.e., "ThisAddIn" in this case.
                    currExplorer = this.Application.ActiveExplorer();
    
                    boo = currExplorer.IsPaneVisible(Outlook.OlPane.olPreview);
                    currExplorer.ShowPane(Outlook.OlPane.olPreview, false);
                    currExplorer.ShowPane(Outlook.OlPane.olToDoBar, true);
                    
                    //navigationPane = ((Outlook.Application)applicationObject).ActiveExplorer().NavigationPane;
                    navigationPane = currExplorer.NavigationPane;
                    navigationPane.IsCollapsed = true;
                }
                catch (Exception ex)
                {
                    //  MessageBox.Show("Error:"+ex);
                }
                finally
                {
                    if (navigationPane != null)
                        Marshal.ReleaseComObject(navigationPane);
                    if (currExplorer != null)
                        Marshal.ReleaseComObject(currExplorer);
                }

    In your code, you're creating a new Outlook.Application object, which is not required, since the Add-In itself will create an Application (this.Application) object which we can use to get the instance for the ActiveExplorer.

    Hope this helps 

    Monday, March 3, 2014 12:51 PM

All replies

  • Hello Bivek,

    Your code looks good, I don't see anything strange in the code except new Outlook application. The ShowPane method of the Explorer class is used for displaying or hiding a specific pane in the explorer. 

    Anyway, I have just tested your code in one of my virtual machines with Outlook 2010 installed. It works as expected, I didn't notice anything strange on my road. So, please make sure that you have no other add-ins installed that can affect to the reading pane. Also please make sure that you have all the latest updates and service packs installed for Office/Outlook 2010 (SP2).


    Monday, March 3, 2014 12:38 PM
  • Hi

    Your code with slight tweaking will work perfectly fine.

    Here is the modified code. I tried it with Outlook 2010 and called the HidePanels() method from the ThisAddIn_Startup event. 

    private void HidePanels()
            {
                Outlook.NavigationPane navigationPane = null;
                Outlook.Explorer currExplorer = null;
                //Outlook.Application app = new Outlook.Application();
                Boolean boo = true;
    
                try
                {
                    //currExplorer = ((Outlook.Application)applicationObject).ActiveExplorer();
                    //currExplorer = app.ActiveExplorer();
                    //Here this keyword represents the current add-in, i.e., "ThisAddIn" in this case.
                    currExplorer = this.Application.ActiveExplorer();
    
                    boo = currExplorer.IsPaneVisible(Outlook.OlPane.olPreview);
                    currExplorer.ShowPane(Outlook.OlPane.olPreview, false);
                    currExplorer.ShowPane(Outlook.OlPane.olToDoBar, true);
                    
                    //navigationPane = ((Outlook.Application)applicationObject).ActiveExplorer().NavigationPane;
                    navigationPane = currExplorer.NavigationPane;
                    navigationPane.IsCollapsed = true;
                }
                catch (Exception ex)
                {
                    //  MessageBox.Show("Error:"+ex);
                }
                finally
                {
                    if (navigationPane != null)
                        Marshal.ReleaseComObject(navigationPane);
                    if (currExplorer != null)
                        Marshal.ReleaseComObject(currExplorer);
                }

    In your code, you're creating a new Outlook.Application object, which is not required, since the Add-In itself will create an Application (this.Application) object which we can use to get the instance for the ActiveExplorer.

    Hope this helps 

    Monday, March 3, 2014 12:51 PM
  • I dont know what was i missing in the above code. I made a work around by creating a view and marking tableview.showreadingpane = false in the view.
    Tuesday, March 4, 2014 7:54 AM