Select an Outlook item programmatically RRS feed

  • Question

  • Hi,
    I am developing an addin for outlook 2003/2007. My addin has a toolsrtip control on form which contain two button 'next' and 'previous'. now i want that when i click 'next' - next item(mail/contact) will select, also it should be highlighted in the item list. similary for previous button.
    Outlook have these functionlity in inspector.but my addin is attached in rightsubpane.
    To implement this i faced following problem.
    1. we can get the Item collection of the current folder and using this we can get next/previous item. but main problem items in collection are not sorted according to the according to currently sort order that user has selected(like arrange by date,subject). how can i get the current sort order. i am able to sort the item collection but i don't know current sort order.
    2.can we highlight the next item programmatically in item list? we can get the command of next-previous at explorer level(without open inspector)
    ( refer i tried this but when i execute this command i got com exception.
    Friday, April 10, 2009 5:33 AM


  • Hello,

    As far as I know there's no interface is provided in Outlook Object Model to Select and Highlight a specific item.

    To you first question, we'll able to know the sort method of the folder by using the View.XML property.
       we could retrieve the XML code which describe the view,i.e.:

        Following two links show how we understand the View XML(view schema)

    To your third question, the exception throws beacuse the CommabdBarButton is not available in Explorer view, it's only available in Inspector.


    We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
    If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Tim Li Friday, April 17, 2009 1:54 AM
    Tuesday, April 14, 2009 10:58 AM