Many of you rely on IMAP commands to display the number of unread emails in your app’s UI, helping users stay informed about new messages. With 4D 20 R7, we’ve enhanced the IMAPTransporter.getBoxList() function, enabling it to retrieve unread email counts and mailbox properties simultaneously, ensuring faster response times.
IMAP Transporter
To optimize the response time, IMAPTransporter.getBoxList() now has new options that let you get email counts for multiple mailboxes in one call. If you want to display all mailbox names with their number of unread emails, total emails, and recent emails, you can do this in one go using the “withBoxInfo” parameter:
var $boxes:=$transporter.getBoxList({withBoxInfo: True})
If you want to check the number of unseen emails for specific mailboxes, you can pass a collection with the names of the mailboxes:
$boxes:=$transporter.getBoxList({withBoxProperties: False; withBoxInfo: True; names: ["INBOX"; "Drafts"]})
These improvements simplify keeping your users updated on their unread emails by delivering all the essential information in just one call. Since everything is handled in a single request, the response times are much faster compared to previous methods. This same improvement has also been applied to Gmail API of 4D Netkit, allowing you to retrieve unread email counts and mailbox properties in a single call for optimal performance.