The Deep End

go to! email!

Thursday, April 14, 2005

Thunderbird Extensions: A Better Way to Navigate Folders

Previously, I introduced a way to navigate folders using nsIMsgDBView.
Unfortunately, this will only work when you have the right folders selected in the tree /navigator/thing on the left of thunderbird. Also, the tree must be fully expanded.

Because that's horrible, there's a different and better way.
var accountManager = Components.classes
var fdrlocal = accountManager.localFoldersServer.rootFolder;
var fdrfoo = fdrlocal.FindSubFolder("Foo");
This will work all the time.

accountManager is a spiffy Component which keeps track of your accounts--and their folders! localFoldersServer.rootFolder will get you the server for "Local Folders," and then the Local Folders folder itself. After that, because fdrlocal is a nsIMsgFolder , feel free to use any of the previously mentioned functions to navigate around. GetSubFolder(String folderName) and the rootFolder property were mentioned in the example and in previous posts, but looking at XulPlanet's documentation would be a good idea.


Post a Comment

<< Home