private void SuppressEventHandler(IItem item, bool findInspector, ref bool cancel)
        {
            Logger.Instance.Trace(this, "Private appointment: suppress");

            // Check if it's an appointment
            IAppointmentItem appointment = item as IAppointmentItem;

            if (appointment == null)
            {
                Logger.Instance.TraceExtra(this, "Private appointment: suppress: not an appointment");
                return;
            }

            // Check if it's private. Confidential is also considered private
            if (appointment.Sensitivity < Sensitivity.Private)
            {
                Logger.Instance.TraceExtra(this, "Private appointment: suppress: not private");
                return;
            }

            // Check if in a shared folder
            using (IFolder parent = item.Parent)
            {
                if (parent == null || !IsSharedOrImpersonatedFolder(parent))
                {
                    Logger.Instance.TraceExtra(this, "Private appointment: suppress: not in a shared folder");
                    return;
                }
            }

            if (findInspector)
            {
                // Find and close any inspector
                using (IInspectors inspectors = ThisAddIn.Instance.GetInspectors())
                    foreach (IInspector inspector in inspectors)
                    {
                        using (inspector)
                            using (IItem inspectItem = inspector.GetCurrentItem())
                            {
                                if (appointment.EntryID == inspectItem.EntryID)
                                {
                                    inspector.Close(InspectorClose.Discard);
                                }
                            }
                    }
            }

            // Private appointment in a shared folder, suppress
            Logger.Instance.TraceExtra(this, "Private appointment: suppressing");
            cancel = true;
            MessageBox.Show(ThisAddIn.Instance.Window,
                            Properties.Resources.SharedFolders_PrivateEvent_Body,
                            Properties.Resources.SharedFolders_PrivateEvent_Title,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning
                            );
        }
        /// <summary>
        /// A method to retrieve all inspectors which can act as an export target
        /// </summary>
        /// <returns>List<string> with inspector captions (window title)</returns>
        public static IDictionary <string, OlObjectClass> RetrievePossibleTargets()
        {
            IDictionary <string, OlObjectClass> inspectorCaptions = new SortedDictionary <string, OlObjectClass>();

            try {
                using (IOutlookApplication outlookApplication = GetOutlookApplication()) {
                    if (outlookApplication == null)
                    {
                        return(null);
                    }

                    if (outlookVersion.Major >= (int)OfficeVersion.OFFICE_2013)
                    {
                        // Check inline "panel" for Outlook 2013
                        using (var activeExplorer = outlookApplication.ActiveExplorer()) {
                            if (activeExplorer != null)
                            {
                                using (var inlineResponse = activeExplorer.ActiveInlineResponse) {
                                    if (canExportToInspector(inlineResponse))
                                    {
                                        OlObjectClass currentItemClass = inlineResponse.Class;
                                        inspectorCaptions.Add(activeExplorer.Caption, currentItemClass);
                                    }
                                }
                            }
                        }
                    }

                    using (IInspectors inspectors = outlookApplication.Inspectors) {
                        if (inspectors != null && inspectors.Count > 0)
                        {
                            for (int i = 1; i <= inspectors.Count; i++)
                            {
                                using (IInspector inspector = outlookApplication.Inspectors[i]) {
                                    string inspectorCaption = inspector.Caption;
                                    using (IItem currentItem = inspector.CurrentItem) {
                                        if (canExportToInspector(currentItem))
                                        {
                                            OlObjectClass currentItemClass = currentItem.Class;
                                            inspectorCaptions.Add(inspector.Caption, currentItemClass);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
            }
            return(inspectorCaptions);
        }
        /// <summary>
        /// Export the image stored in tmpFile to the Inspector with the caption
        /// </summary>
        /// <param name="inspectorCaption">Caption of the inspector</param>
        /// <param name="tmpFile">Path to image file</param>
        /// <param name="attachmentName">name of the attachment (used as the tooltip of the image)</param>
        /// <returns>true if it worked</returns>
        public static bool ExportToInspector(string inspectorCaption, string tmpFile, string attachmentName)
        {
            using (IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) {
                if (outlookApplication == null)
                {
                    return(false);
                }
                if (outlookVersion.Major >= (int)OfficeVersion.OFFICE_2013)
                {
                    // Check inline "panel" for Outlook 2013
                    using (var activeExplorer = outlookApplication.ActiveExplorer()) {
                        if (activeExplorer == null)
                        {
                            return(false);
                        }
                        var currentCaption = activeExplorer.Caption;
                        if (currentCaption.StartsWith(inspectorCaption))
                        {
                            using (var inlineResponse = activeExplorer.ActiveInlineResponse) {
                                using (IItem currentItem = activeExplorer.ActiveInlineResponse) {
                                    if (canExportToInspector(inlineResponse))
                                    {
                                        try {
                                            return(ExportToInspector(activeExplorer, currentItem, tmpFile, attachmentName));
                                        } catch (Exception exExport) {
                                            LOG.Error("Export to " + currentCaption + " failed.", exExport);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                using (IInspectors inspectors = outlookApplication.Inspectors) {
                    if (inspectors == null || inspectors.Count == 0)
                    {
                        return(false);
                    }
                    LOG.DebugFormat("Got {0} inspectors to check", inspectors.Count);
                    for (int i = 1; i <= inspectors.Count; i++)
                    {
                        using (IInspector inspector = outlookApplication.Inspectors[i]) {
                            string currentCaption = inspector.Caption;
                            if (currentCaption.StartsWith(inspectorCaption))
                            {
                                using (IItem currentItem = inspector.CurrentItem) {
                                    if (canExportToInspector(currentItem))
                                    {
                                        try {
                                            return(ExportToInspector(inspector, currentItem, tmpFile, attachmentName));
                                        } catch (Exception exExport) {
                                            LOG.Error("Export to " + currentCaption + " failed.", exExport);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }