MozillaZine

How can i Create Folder and SubFolder in a java script

Talk about add-ons and extension development.
nickhere
 
Posts: 40
Joined: September 29th, 2009, 1:57 pm

Post Posted November 11th, 2018, 10:56 am

I have the account name I want to create a folder under it.
I have the account name folder name I want to create a subfolder under it

morat
 
Posts: 3073
Joined: February 3rd, 2009, 6:29 pm

Post Posted November 11th, 2018, 1:09 pm

Try these:

Code: Select all
gFolderTreeController.newFolder();

Code: Select all
var folder = gFolderDisplay.displayedFolder;
var rootFolder = folder.rootFolder;
gFolderTreeController.newFolder(rootFolder);

Reference
http://dxr.mozilla.org/comm-esr60/search?q=ftc_newFolder

nickhere
 
Posts: 40
Joined: September 29th, 2009, 1:57 pm

Post Posted November 11th, 2018, 2:51 pm

Thank you.
you finally got me in the right direction
problem is it brings up a dialog box
i need it to create with out a dialog box
supply the root and the folder name to write

morat
 
Posts: 3073
Joined: February 3rd, 2009, 6:29 pm

Post Posted November 11th, 2018, 3:52 pm

nsIMsgFolder.createSubfolder
http://dxr.mozilla.org/comm-esr60/source/mailnews/base/public/nsIMsgFolder.idl

Code: Select all
var folder = gFolderDisplay.displayedFolder;
var rootFolder = folder.rootFolder;
rootFolder.createSubfolder("Example", msgWindow);

Code: Select all
var rootUri = "imap://username%40gmail.com@imap.googlemail.com";
var rootFolder = MailUtils.getFolderForURI(rootUri);
rootFolder.createSubfolder("Example", msgWindow);

nickhere
 
Posts: 40
Joined: September 29th, 2009, 1:57 pm

Post Posted November 11th, 2018, 4:00 pm

ok it works
it create a example folder in every folder

Code: Select all
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);
   console.log(account.incomingServer.prettyName);
  account.incomingServer.rootFolder.createSubfolder("Example", msgWindow);
}

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 2 guests