firemail

标题: 常用内容获取方法 [打印本页]

作者: hechengjin    时间: 2016-3-27 23:36
标题: 常用内容获取方法
https://developer.mozilla.org/en ... rd/Account_examples
Iterate over all known accountsvar acctMgr = Components.classes["@mozilla.org/messenger/account-manager;1"                        .getService(Components.interfaces.nsIMsgAccountManager);var accounts = acctMgr.accounts;if (accounts.queryElementAt) { // Gecko 17+  for (var i = 0; i < accounts.length; i++) {    var account =accounts.queryElementAt(i, Components.interfaces.nsIMsgAccount);    // Do something with account  }} else { // Gecko < 17  for (var i = 0; i < accounts.Count(); i++) {    var account =accounts.QueryElementAt(i, Components.interfaces.nsIMsgAccount);    // Do something with account  }}















Introspect the details of particular accounts (names, parameters, etc.)var acctMgr = Components.classes["@mozilla.org/messenger/account-manager;1"                        .getService(Components.interfaces.nsIMsgAccountManager);var accounts = acctMgr.accounts;for (var i = 0; i < accounts.length; i++) {  var account = accounts.queryElementAt(i,Components.interfaces.nsIMsgAccount);  Application.console.log(account.key); // account.incomingServer is an nsIMsgIncomingServer // account.identities is an nsISupportsArray of nsIMsgIdentity objects //                    you can loop through it just like acctMgr.accounts above // account.defaultIdentity is an nsIMsgIdentity}










Iterate over the folders in an accountvar acctMgr = Components.classes["@mozilla.org/messenger/account-manager;1"                        .getService(Components.interfaces.nsIMsgAccountManager);var accounts = acctMgr.accounts;for (var i = 0; i < accounts.length; i++) {  var account = accounts.queryElementAt(i,Components.interfaces.nsIMsgAccount);  var rootFolder = account.incomingServer.rootFolder; // nsIMsgFolder  Application.console.log(rootFolder.prettiestName);  if (rootFolder.hasSubFolders) {   var subFolders = rootFolder.subFolders; // nsIMsgFolder    while(subFolders.hasMoreElements()) {      var folder = subFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder);      Application.console.log(folder.prettiestName);    }  }}






欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3