views:

291

answers:

1

I am reading the book "Programming Applications for Microsoft Office Outlook : 2007". In the sample code..

private void Application_ItemContextMenuDisplay(
    Microsoft.Office.Core.CommandBar CommandBar,
    Microsoft.Office.Interop.Outlook.Selection Selection)
{
    OutlookItem oItem = new OutlookItem(Selection[1]);

    //...
}

The problem with the above code is the I could not find OutlookItem class anywhere. Since I am new to Office/Outlook programming, I need some guidance up on this end. Please let me know how to access the items in Selection as a generic outlook item, instead of specifying or casting as MailItem or AppointmentItem.

+2  A: 

There is no class in the Outlook Object Model that is generic like OutlookItem, the authors of the above mentioned booke provided OutlookItem as an helper class. In general the helper class uses reflection to expose methods common to all the outlook items.

So the thing to take from this answer would be, there is no Item-level generic class in the current Outlook Object Model, and hopefully people on the outlook team will include one in the future.

Srikanth Remani