예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="delete"></param>
        internal static void MoveFolderContents(Outlook.Folder folder, bool delete)
        {
            if (folder == null)
            {
                return;
            }
            using var form = new ProjectSelectFormHost();
            var result = form.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            var sharedFolder = GetSharedFolder(form.SelectedFolders[0]);

            if (sharedFolder == null)
            {
                throw new ArgumentNullException(nameof(sharedFolder), @"No shared folder.");
            }
            foreach (var item in folder.Items)
            {
                if (item is Outlook.MailItem mail)
                {
                    mail.Move(sharedFolder);
                }
            }

            if (delete)
            {
                folder.Delete();
            }
        }
예제 #2
0
        //gavdcodeend 13

        //gavdcodebegin 14
        private void btnDeleteFolder_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.Application myApplication = Globals.ThisAddIn.Application;

            string folderToFind = "My New Folder";

            Outlook.Folder myInBox = (Outlook.Folder)myApplication.ActiveExplorer().
                                     Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

            Outlook.Folder myFolder = (Outlook.Folder)myInBox.Folders[folderToFind];

            if (myFolder != null)
            {
                myFolder.Delete();
            }
        }
 public void Delete()
 {
     _folder.Delete();
 }