The Mail feature, a huge feature set. The first part was released with 4D v17 R4, and since then we have delivered more and more functionalities.
4D v19 is no exception, as it brings new functions to help you manage your mailboxes by programming. That includes creating, renaming, and deleting mailboxes. A mailbox is displayed as a folder in email clients such as Microsoft Outlook or Apple Mail.
Create a mailbox
To create a new mailbox, use the createBox() function. For example, if you want to create a new “Invoices” mailbox at the root:
$status:=$transporter.createBox("Invoices")
And if you want to add some children mailboxes to your mailbox, enter the full path with the IMAP server’s separator character:
// create mailboxes name with separator() function
$name1:="Invoices"+$transporter.getDelimiter()+"Atlas Corp"
$name2:="Invoices"+$transporter.getDelimiter()+"Nova Orion Industries"
// Adds new mailboxes related to "Invoices"
$status:=$transporter.createBox($name1)
$status:=$transporter.createBox($name2)
Here is what you obtain in your mail browser:
rename a mailbox
If you want to rename your “Invoices” mailbox in “Bills”, use the renameBox() method:
$status:=$transporter.renameBox("Invoices"; "Bills")
Here is what you obtain in the mail browser:
delete a mailbox
If a mailbox is no longer used, you can delete it with the deleteBox() function:
$name3:="Bills"+$transporter.getDelimiter()+"Nova Orion Industries"
$status:=$transporter.deleteBox($name3)
Here is what you otbain in your mail browser:
Subscribe to a mailbox
With the subscribe() and unsubscribe() functions, you can define which mailboxes should be displayed as favorites by IMAP clients.
$name4:="Bills"+$transporter.getDelimiter()+"Atlas Corp"
$status:=$transporter.subscribe($name4)
Check out the documentation and the HDI above to learn more about the new functions!