Closed eyalroz closed 3 years ago
Given a nsIMsgFolder f
, you can get the root folder as f.server.rootFolder
. Now, for many things, it's actually the root folder you want rather than the account. If you really need the nsIMsgAccount, you can get it with this function:
function rootFolderToAccount(rootFolder) {
for (let account of MailServices.accounts.accounts) {
if (rootFolder == account.incomingServer.rootMsgFolder)
return account;
}
return null;
}
yes, it's an iteration :-(
let server = folder.server;
let account = MailServices.accounts.FindAccountForServer(server);
But I guess it is doing the iteration internally as well.
Suppose I have a folder (i.e. an nsIMsgFolder instance). How do I get its account? I suppose I could parse its URI to get some string ID, but is there a more civilized and idiomatic way to do this?
PS - Asking about regular Thunderbird extension/core code, not WebExtensions.