4D Blog

Home Product Create, delete, and rename mailboxes with IMAP

Create, delete, and rename mailboxes with IMAP

April 23, 2021

Product

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.

HDI Mailboxes management 

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:

blank

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:

blank

 

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!

Discuss

Tags IMAP, Mail, v19

Latest related posts

  • July 17, 2025

    Managing Calendar Events with Microsoft 365 or Google in 4D: Create, Update, Delete

  • July 17, 2025

    Sort UUIDs with version 7

  • July 16, 2025

    Recursive Dependency Management: Smarter, Deeper, Safer

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R9 20 R10 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R9 20 R10 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy