I have added a ContextMenuItem to the ContextMenu for Outlook appointments.
The problem is that I cannot figure out how to get the Appointment object. In the event I get an IRibbonControl, and its Context property should contain the Appointment, but it contains a Selection instead. I can't use the Selection to get to the Appointment as far as I can see.
This page is where I'm coming from: https://msdn.microsoft.com/en-us/library/office/ff863278%28v=office.14%29.aspx
Anyone knows of how to get the Appointment?
The Selection object contains the AppointmentItem object selected on the picture. For example:
Object selObject = Selection[1];
if (selObject is Outlook.MailItem)
{
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 + ".";
}
See How to: Programmatically Determine the Current Outlook Item for more information.