How to programmatically detect a new Outlook item created from Home Ribbon & # 8594; New items

I have an Outlook add-in, which is a new Ribbon tab that connects to my server database so that some user data is associated with an Outlook object.

This feed tab is currently displayed in the Mail Item.

I am expanding it to show in the Tasks and Calendar items (Appointment, Meeting, etc.).

Currently, the way to define a newly created item is as follows →

Microsoft.Office.Interop.Outlook.Application interopApplication = ThisAddIn.Application.Application if (interopApplication.ActiveExplorer().CurrentFolder.DefaultItemType.ToString() != "olTaskItem") { .... } 

Thus, I can identify the folder and the new item associated with it (for example, in the Inbox, Create a new mail item, I create a new appointment in the calendar, etc.)

Now that I am in my inbox and I click New Destination, it identifies the new item created as olMailItem , not olAppointmentItem . The same thing happens when I am in the Calendar window and I click on the "New mail item".

My question is: how to identify a new item created regardless of which folder I am in?

+4
source share
1 answer

You should check MessageClass ActiveInspector to determine OlItemType .

 string itemClass = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem.MessageClass; if (itemClass == "IPM.Appointment") // you have a calendar item else if (itemClass == "IPM.Task") // you have a task item else if (itemClass == "IPM.Note") // you have a message item 
+1
source

All Articles