none
Programatically we are not able to get MRU list of Move To Folders in 2016. RRS feed

  • Question

  • In the process of Migrating our outlook add-in project to Outlook 2016, we are facing issue in getting MRU list of Move To Folders.

    Earlier in add-in 2010 project we used to get the handle of Standard CommandBars and get the handle of particular Move to Folder button. Then we used to get the Recently used folders name by looping the  “Move To folder” controls collection.

    In Outlook 2016 ,We belie  Micorsof implemented lazay loading concept.

    Here we are able to get the handle of Standard CommandBar but it didn’t load any of the child controls. We are getting  cmdBar.Controls.Count = 0.

    Could any one suggest us, is there any other alternate way available in Outlook2016 to Get the MRU list  of Move To Folder?

    Code Snippet:

                    explorer = Globals.ThisAddIn.Application.Explorers[1];

                    bool barExists = false;

                    if (explorer != null)

                    {

                        foreach (Office.CommandBar cmdBar in explorer.CommandBars)

                        {

                            if (cmdBar.Name == "Standard")

                            {

                                foreach (Office.CommandBarControl ctl in cmdBar.Controls)

                                {

                                    if (ctl.Id == 2778)

                                    {

                                        btnMoveToFolderOutLook = (Office.CommandBarPopup)ctl;

                                        Logging.Log("Got handle for MoveToFolder Standard Button.", true);

                                    }

                                }

                            }

                            if (cmdBar.Name == "WGM Outlook Actions")

                            {

                                barExists = true;

                                cmdBar.Visible = true;

                                break;

                            }

                        }

                    }

                    if (btnMoveToFolderOutLook != null)

                    {

                        ///If error came which needs reseting of menu.

                        try

                        {

                            controlsCount = btnMoveToFolderOutLook.Controls.Count;

                        }

                        catch (System.Exception ex)

                        {

                            Logging.Log("GetRecentFoldersNamesFromOutLook: Error came which needs reseting of menu.", true);

                            Logging.Log(ex, MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name);

                            //  ResetMenu();

                            controlsCount = btnMoveToFolderOutLook.Controls.Count;

                        }

                        for (int i = 1; i < controlsCount; i++)

                        {

                            if (btnMoveToFolderOutLook.Controls[i] is Office.CommandBarButton)

                            {

                                string tempFolderName = ((Office.CommandBarButton)btnMoveToFolderOutLook.Controls[i]).Caption;

                                if (tempFolderName.ToUpper() != folderName.ToUpper())

                                {

                                    folderNames += tempFolderName + "■";

                                    folderName = tempFolderName;

                                }

                            }

                        }


    Murari S

    Wednesday, March 9, 2016 1:06 AM

Answers

All replies