To answer my own question, the first thing that needs to be done is fix
the multitude of spelling mistakes I have in the code (I typed it out
from looking at the code on another machine - bad bad bad). Secondly a
call to Folder.GetSubFolders(); should do the trick. Hopefully this
saves someone else the trouble I've had to get this to work.
Dan
Dan Parent wrote:
> I'd really like to know what is the minimum amount of work (starting
> from scratch) to get the datasource populated for folders. What I would
> like to avoid:
>
> creating a tree
> using a msgWindow
>
> I'd really like to be able to access mail resources without having the
> actual messenger application open. I really want access to the users
> mail folders and messages from outside of messenger. I see the API and
> so far I've gone so far as to find the attributes of the INBOX for all
> the accounts a user may have but I can't seem to get beyond that. What
> I seem to be missing is the link where the datasource is actually
> filled. Here's some quick code that I've been playing with that, so far
> gets me the inbox folder attributes. If I call any functionality on the
> folder I don't get anything back, for example calling
> getNumUnread(true), always returns -1.
>
> start example:
>
> function tryRDF()
> {
> try
> {
> RDF =
> Components.clases["@mozilla.org/rdf/rdf-service;1"].getService();
> RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
> }
> catch(ex)
> {
> alert("no RDF?");
> return;
> }
> var AccountManager =
> Components.classes["@mozilla.org/messenger/account-manager;1"];
> var AccountManagerService = AccoutnManagerComponent.getService();
> var AccountManager =
> AccountManagerService.QueryInterface(Components.interfaces.nsIMsgAccountManager);
>
> var Accounts = AccountManager.accounts;
>
> for (var i = 0; i < Accounts.Count(); i++)
> {
> var Account = Accounts.GetlElementAt(i);
> Account =
> Account.QueryInterface(Components.interfaces.nsIMsgAccount);
> IncomingServer = Account.incomingServer;
> if (IncomingServer.hostName != "Local Folders")
> {
> var Folder;
> var Mailbox = "mailbox://" + IncomingServer.username + "@" +
> IncomingServer.hostName + "/INBOX";
> if (IncomingServer.type == "imap" || IncomingServer.type ==
> "pop3")
> {
> Folder = RDF.GetResource(MailBox);
> Folder =
> Folder.QueryInterface(Components.interfaces.nsIMsgFolder);
> alert("pretty name - " + Folder.prettiestName);
> alert("Unread msgs = " + Folder.getNumUnread(true));
> }
> else
> {
> dump("not a mail account");
> }
> }
> }
> }
>
> what I get:
>
> first alert returns:
> pretty name - INBOX
> second alert returns:
> Unread msgs = -1
>
> There are currently 22 unread messages in one of the INBOX folders for
> the accounts I have setup. What am I missing?
>
> Dan
>
> (to get to me directly, remove the -nospam's from my reply address)
>