private void OnUnpatchedFolderDiscovered(IFolder folder)
        {
            string strippedName = folder.Name.StripSuffix(SUFFIX_CONTACTS);

            Logger.Instance.Debug(this, "Patching secondary contacts folder: {0}", strippedName);

            // To patch we need to do the following
            // 1) Update the sync type from 18 to 14
            // 2) Update the container class from Note to Contact
            // 3) Patch the name
            // Note that the above steps need to be done in this order and individually for this to work.
            //
            // At some point after 2 we also need to restart Outlook to make it appear in the list of contact folders.

            // Somehow some properties fail if we do it in the event handler, post to ui thread
            ThisAddIn.Instance.InUI(() =>
            {
                // Stage 1

                // Sync type
                Logger.Instance.Trace(this, "Setting sync type");
                folder.SetProperty(OutlookConstants.PR_EAS_SYNCTYPE, (int)OutlookConstants.SyncType.UserContact);

                // Container type
                Logger.Instance.Trace(this, "Setting container class");
                folder.SetProperty(OutlookConstants.PR_CONTAINER_CLASS, "IPF.Contact");

                // Update the icon.
                using (IExplorer explorer = ThisAddIn.Instance.GetActiveExplorer())
                    using (ICommandBars cmdBars = explorer.GetCommandBars())
                        using (IPicture icon = cmdBars.GetMso("ShowContactPage").GetPicture(new Size(16, 16)))
                        {
                            folder.SetCustomIcon(icon);
                        }

                // Patch the name
                Logger.Instance.Trace(this, "Patching name");
                folder.Name            = strippedName;
                folder.ShowAsOutlookAB = true;

                // Save the folder
                folder.Save();

                // Do another send receive to start syncing
                ThisAddIn.Instance.SendReceive();

                // Warn about a restart
                DoWarnRestart(folder);
            }, false);
        }
        public OutlookImageList(params string[] icons)
        {
            Images            = new ImageList();
            Images.ColorDepth = ColorDepth.Depth32Bit;
            Images.ImageSize  = new Size(16, 16);

            using (IExplorer explorer = ThisAddIn.Instance.GetActiveExplorer())
                using (ICommandBars cmdBars = explorer.GetCommandBars())
                {
                    foreach (string id in icons)
                    {
                        Images.Images.Add(cmdBars.GetMso(id).GetImage(Images.ImageSize));
                    }
                }
        }