How to: Display Selected Items in the Active Explorer
This example shows how to use the OutlookItem helper class to conveniently display all the items selected in the active Explorer window.
The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007, from Microsoft Press (ISBN 9780735622494, copyright Microsoft Press 2007, all rights reserved).
The Selection object contains the set of Outlook items currently selected in the active Outlook explorer. Neither the active explorer, represented by ActiveExplorer(), nor the set of selected items indicates the type of the items that are selected. Normally, you would have to first identify the item type and then call the specific Display method for that type. Because the Display method is common to all Outlook items objects and the OutlookItem helper class includes this method, you can take advantage of the helper class, by declaring an instance of the OutlookItem object, myItem, and using myItem.Display to display each item in the selection. You can see the implementation of the OutlookItem helper class in How to: Create a Helper Class to Access Common Outlook Item Members
If you use Microsoft Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 14.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.