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:
- Get the active explorer (Globals.thisaddin.application.activeexplorer)
- Set the current folder explorer.currentfolder = Folder A
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
精彩评论