New Managed Code Examples for Outlook 2010

With the announcement of Microsoft Office 2010 being released to manufacturing (RTM) today, I’d like to bring your attention to the new Microsoft Outlook 2010 Primary Interop Assembly (PIA) Reference. For those of you familiar with developing managed solutions for Outlook, you now have on MSDN a currently most up-to-date set of managed documentation for the Outlook 2010 object model.

The Outlook 2010 PIA Reference supports managed solutions to take advantage of new extensibility features in Outlook 2010, for example, multiple Exchange accounts, the much enhanced conversation view, and solution-specific folders under the new Solutions Module of the Navigation Pane, by using new objects such as AccountSelector, Conversation,  and SolutionsModule. Add-ins can use the Office Fluent user interface extensibility to customize the explorer and inspector ribbons, the menus and context menus, and Microsoft Office Backstage view in the Outlook 2010 user interface.

The Outlook 2010 PIA Reference now provides almost 100 managed code examples to demonstrate how to do common tasks using the Outlook PIA. Browse the Outlook 2010 PIA Reference for its rich set of code examples! Be aware of a few developer issues when you upgrade existing managed solutions to Outlook 2010. If you are used to writing COM add-ins and are new to writing managed solutions for Outlook, start with Setting Up to Use the Outlook PIA.

Before signing off, I’d like to list one of my favorite new code examples in C#, How to: Get and Enumerate Selected Conversations, which showcases the enhanced conversation view. It shows how to obtain and enumerate selected conversations by using the new Selection.GetSelection method.

private void DemoConversationHeadersFromSelection()


    // Obtain Inbox.

    Outlook.Folder inbox =



        as Outlook.Folder;

    // Set ActiveExplorer.CurrentFolder to Inbox.

    // Inbox must be current folder.

    Application.ActiveExplorer().CurrentFolder = inbox;

    // Ensure that current view is TableView.

    if (inbox.CurrentView.ViewType ==



        Outlook.TableView view =

            inbox.CurrentView as Outlook.TableView;

        if (view.ShowConversationByDate == true)


            Outlook.Selection selection =


            Debug.WriteLine("Selection.Count = " + selection.Count);

            // Call GetSelection to create a Selection object

            // that contains ConversationHeader objects.

            Outlook.Selection convHeaders =



                as Outlook.Selection;

            Debug.WriteLine("Selection.Count (ConversationHeaders) = "

                + convHeaders.Count);

            if (convHeaders.Count >= 1)


                foreach (Outlook.ConversationHeader convHeader in convHeaders)


                    // Enumerate the items in the ConversationHeader.

                    Outlook.SimpleItems items = convHeader.GetItems();

                    for (int i = 1; i <= items.Count; i++)


                        // Enumerate only MailItems in this example.

                        if (items[i] is Outlook.MailItem)


                            Outlook.MailItem mail =

                                items[i] as Outlook.MailItem;


                                + " Received:" + mail.ReceivedTime);










Comments (0)

Skip to main content