private void CurrentExplorer_Event() { Outlook.MAPIFolder selectedFolder = this.Application.ActiveExplorer().CurrentFolder; bool SelectedObjectIsMail = false; try { if (this.Application.ActiveExplorer().Selection.Count > 0) { Object selObject = this.Application.ActiveExplorer().Selection[1]; if (selObject is Outlook.MailItem) { SelectedObjectIsMail = true; } } ThisRibbonCollection ribbonCollection = Globals.Ribbons[Globals.ThisAddIn.Application.ActiveInspector()]; if (SelectedObjectIsMail) { } } catch (Exception) { } }
private void CurrentExplorer_Event() { Outlook.MAPIFolder selectedFolder = this.Application.ActiveExplorer().CurrentFolder; bool SelectedObjectIsMail = false; try { if (this.Application.ActiveExplorer().Selection.Count > 0) { Object selObject = this.Application.ActiveExplorer().Selection[1]; if (selObject is Outlook.MailItem) { SelectedObjectIsMail = true; /* * Outlook.MailItem mailItem = (selObject as Outlook.MailItem); * itemMessage = "The item is an e-mail message." + " The subject is " + mailItem.Subject + "."; * mailItem.Display(false); */ } else if (selObject is Outlook.ContactItem) { /*Outlook.ContactItem contactItem = (selObject as Outlook.ContactItem); * itemMessage = "The item is a contact." + " The full name is " + contactItem.Subject + "."; * contactItem.Display(false); */ } else if (selObject is Outlook.AppointmentItem) { /* * Outlook.AppointmentItem apptItem = (selObject as Outlook.AppointmentItem); * itemMessage = "The item is an appointment." + " The subject is " + apptItem.Subject + "."; */ } else if (selObject is Outlook.TaskItem) { /* * Outlook.TaskItem taskItem = (selObject as Outlook.TaskItem); * itemMessage = "The item is a task. The body is " + taskItem.Body + "."; */ } else if (selObject is Outlook.MeetingItem) { /* * Outlook.MeetingItem meetingItem = (selObject as Outlook.MeetingItem); * itemMessage = "The item is a meeting item. " + "The subject is " + meetingItem.Subject + "."; */ } } ThisRibbonCollection ribbonCollection = Globals.Ribbons[Globals.ThisAddIn.Application.ActiveInspector()]; if (SelectedObjectIsMail) { } } catch (Exception) { } }
// protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject() #region action when a new mail is selected private void CurrentExplorer_Event() { //if (currentExplorer == null) return null Outlook.MAPIFolder selectedFolder = this.Application.ActiveExplorer().CurrentFolder; bool SelectedObjectIsMail = false; //String expMessage = "Your current folder is " + selectedFolder.Name + ".\n"; // String itemMessage = "Item is unknown."; try { if (this.Application.ActiveExplorer().Selection.Count > 0) { Object selObject = this.Application.ActiveExplorer().Selection[1]; if (selObject is Outlook.MailItem) { SelectedObjectIsMail = true; /* * Outlook.MailItem mailItem = * (selObject as Outlook.MailItem); * itemMessage = "The item is an e-mail message." + * " The subject is " + mailItem.Subject + "."; * mailItem.Display(false); */ } else if (selObject is Outlook.ContactItem) { /*Outlook.ContactItem contactItem = * (selObject as Outlook.ContactItem); * itemMessage = "The item is a contact." + * " The full name is " + contactItem.Subject + "."; * contactItem.Display(false); */ } else if (selObject is Outlook.AppointmentItem) { /* * Outlook.AppointmentItem apptItem = * (selObject as Outlook.AppointmentItem); * itemMessage = "The item is an appointment." + * " The subject is " + apptItem.Subject + "."; */ } else if (selObject is Outlook.TaskItem) { /* * Outlook.TaskItem taskItem = * (selObject as Outlook.TaskItem); * itemMessage = "The item is a task. The body is " + taskItem.Body + "."; */ } else if (selObject is Outlook.MeetingItem) { /* * Outlook.MeetingItem meetingItem = * (selObject as Outlook.MeetingItem); * itemMessage = "The item is a meeting item. " + * "The subject is " + meetingItem.Subject + "."; */ } } // expMessage = expMessage + itemMessage; ThisRibbonCollection ribbonCollection = Globals.Ribbons[Globals.ThisAddIn.Application.ActiveInspector()]; if (SelectedObjectIsMail) { /* Ribbon1. * ribbonCollection.Ribbon1.comboBox1.Text = "Hello World"; */ } } catch (Exception) { // expMessage = ex.Message; } // MessageBox.Show(expMessage); }