private void OnButtonClick(object sender, RibbonControlEventArgs e) { Outlook.Explorer explorer = (Outlook.Explorer)e.Control.Context; if (explorer.Selection.Count == 0) { return; } if (this._folders.Count == 0) { PopulateFolders(explorer.Application.Session.Folders, _folders); } var window = new FolderSelectionWindow(); window.DataContext = _folders; var result = window.ShowDialog(); if (result.HasValue && result.Value) { try { foreach (var item in explorer.Selection) { if (item is Outlook.MailItem) { Outlook.MailItem mailItem = (Outlook.MailItem)item; mailItem.UnRead = false; mailItem.Move(window.SelectedFolder); } } } catch (COMException ce) { System.Windows.Forms.MessageBox.Show(ce.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } catch { throw; } } }