none
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?
    3.how we can get the command of next-previous at explorer level(without open inspector)
    ( refer http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/39869e1c-5685-4804-b5ac-db8ddf0b3b91/). i tried this but when i execute this command i got com exception.
    Friday, April 10, 2009 5:33 AM

Answers

  • 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.:
             Application.ActiveExplorer().CurrentFolder.CurrentView.XML

        Following two links show how we understand the View XML(view schema)
             http://msdn.microsoft.com/en-us/library/aa155658(office.10).aspx 
             http://msdn.microsoft.com/en-us/library/aa140157(office.10).aspx#odc_xmlviewdef_table

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

    Thanks



    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 colbertz@microsoft.com.
    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