I am writing my first ribbon-add-in for outlook 2016 using Visual Studio 2015 and C#. After some difficulties finally I got my "hello world" working. But what I would like to do now is access the currently displayed outlook item in my C# code which can either be a mailitem or an appointment request or a meeting. Unfortunately it is hard to find as I am not quite sure, what to look for. Maybe someone has some hints or maybe an coding example how to start. My ribbon is placed in Microsoft.Outlook.Explorer, Microsoft.Outlook.Appointment, Microsoft.Outlook.Mail.Read, Microsoft.Outlook.Mail.Compose
Thanks for your help
here my example code
private void btnIssueFromMail_Click(object sender, RibbonControlEventArgs e)
{
//Read Mail item
string subject;
string body;
}
Use RibbonControlEventArgs.Control.Context
and cast it to Inspector object. You can then use Inspector.CurrentItem
to cast to the appropriate item type (e.g. MailItem
or AppointmentItem
).