Example #1
0
        protected override void ExecuteAction(IResourceList selectedResources)
        {
            Trace.WriteLine(">>> CreateFolderAction.ExecuteAction");
            PairIDs folderIDs = PairIDs.Get(selectedResources[0]);

            try
            {
                IEFolder folder =
                    OutlookSession.OpenFolder(folderIDs.EntryId, folderIDs.StoreId);
                if (folder == null)
                {
                    return;
                }
                using ( folder )
                {
                    IEFolder subFolder = folder.CreateSubFolder(_folderName);
                    if (subFolder != null)
                    {
                        using ( subFolder )
                        {}
                    }
                }
            }
            catch (COMException exception)
            {
                Tracer._TraceException(exception);
                MsgBox.Error("Outlook Plugin", "Cannot create new folder.\n" +
                             "Reason is: folder with such name already exists.");
            }
            catch (System.UnauthorizedAccessException exception)
            {
                Tracer._TraceException(exception);
                MsgBox.Error("Outlook Plugin", "Cannot create new folder.\n" + exception.Message);
            }
            Trace.WriteLine("<<< CreateFolderAction.ExecuteAction");
        }