Using the MailClient you can list folders, check their presence, as well as create and delete them:
Operations expecting a folderPath argument will treat this the following way: Folder PathDescription ExampleNULLThis is interpreted as meaning the <Inbox> folder.path beginning with / This is interpreted as a path from the mail connections root folder./Archive/Orderspath not beginning with / This is interpreted as a relative path to the <Inbox> folder, so translates to /<Inbox>/Archive/Orders.Archive/Orders The intention of this behavior is to abstract away the fact that <Inbox> has many different names depending on the connection, i.e. IMAP typically uses INBOX, Exchange calls it Inbox, and a German Exchange calls it Posteingang.Also note that POP3 does not support folders other than <Inbox>. Hence when you specify a POP3 connection, folderPath parameters other than NULL will raise an exception.
Operations
listFolders
ParameterTypesDirectionDescriptionAllowed Values / Exampleconnection(25.1) JavaMail Library Reference#ConnectioninSpecify the Connection object defining the mail server connection parameters to use (see (25.1) Mail Server Connection).parentFolderStringinSpecify the path to the parent folder. See note regarding folder handling.NULLList folders below <Inbox>.\List folders below root folder.a pathList folders below given path.foldersArray of StringreturnReturns a recursive list of sub-folder paths.ordersorders/incomingorders/incoming/accepted
existsFolderPath
ParameterTypesDirectionDescriptionAllowed Values / Exampleconnection(25.1) JavaMail Library Reference#ConnectioninSpecify the Connection object defining the mail server connection parameters to use (see (25.1) Mail Server Connection).folderPathStringinSpecify the path to the folder to check. See note regarding folder handling.orders/outgoingexistsBooleanreturnReturns if the given folder is existent on the mail server.trueFolder exists.falseFolder does not exist.
createFolderPath
ParameterTypesDirectionDescriptionAllowed Values / Exampleconnection(25.1) JavaMail Library Reference#ConnectioninSpecify the Connection object defining the mail server connection parameters to use (see (25.1) Mail Server Connection).folderPathStringinSpecify the path to the folder to be created. See note regarding folder handling.orders/outgoing
deleteFolderPath
ParameterTypesDirectionDescriptionAllowed Values / Exampleconnection(25.1) JavaMail Library Reference#ConnectioninSpecify the Connection object defining the mail server connection parameters to use (see (25.1) Mail Server Connection).folderPathStringinSpecify the path to the folder to be deleted recursively. See note regarding folder handling.orders/incoming/accepted Delete folder accepted from folder incoming.orders Delete folder orders and all sub-folders and contents.