4
votes

I have a Outlook Add-in which is a new Ribbon tab which connects to my server database for some custom data to be associated with an Outlook Object.

This ribbon tab shows in Mail Item as of now.

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

Currently the way I am determining the new item created is as follows -->

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

This way I am able to determine the folder and its associated new item (like in Inbox, I create New Mail Item, in Calendar I create new Appointment etc)

Now when I am in Inbox, and I click on New Appointment, it identifies the new item created as olMailItem and not as olAppointmentItem. Same is the case when I am in Calendar view and I click on New Mail Item.

My Question is how do I determine the new item created irrespective from which folder I am in?

1

1 Answers

1
votes

You should check the MessageClass of the ActiveInspector method to determine the 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