开发者

Expand/collapse folders in the Outlook navigation pane programmatically

开发者 https://www.devze.com 2022-12-19 15:14 出处:网络
I am writing an add-in for Outlook using C#. Is there are way to programmatically expand and collapse folders in the Outlook 2007 folders navigation pane? Also, is there an event fired when开发者_开发

I am writing an add-in for Outlook using C#. Is there are way to programmatically expand and collapse folders in the Outlook 2007 folders navigation pane? Also, is there an event fired when开发者_开发问答 a folder is expanded?


Outlook does not expose events that will allow you to expand or collapse the folders in the treeview. You may be able to do this using the Windows API.


There might be a way to expand (but not to collapse).

Basically what you need to do is to go through your sub folders one by one during each step make the sub folder your current folder.

I have tested this in Outlook 2010 (VSTO) on addin startup. So if you have the Parent Folder Folder A and its sub folders Folder A1, Folder A2 and Folder A3.

In order to expand Folder A do the following:

  1. Get the active explorer (Globals.thisaddin.application.activeexplorer)
  2. Set the current folder explorer.currentfolder = Folder A
  3. Now loop through all sub folders under Folder A and make each sub folder the current folder:
    (The code should be something like this)

    Subfolders = FolderA.Folders
    For Each folder as outlook .folder in Subfolders
    Explorer.currentfolder = folder
    Next Folder

This method works for me so hope this would be hopeful

0

精彩评论

暂无评论...
验证码 换一张
取 消