IMAP: Mailbox Id and mail keywords

4D v20 brings two very useful features to IMAP Transporters!

Interacting with some IMAP mail servers and clients requires to manage custom keywords in mails, and benefit from some of their specific features.

We also added the mailbox ID support in our IMAP Transporter so that you can identify a given mailbox even after it is renamed.

Custom keywords

Because some IMAP servers allow user to define custom keywords, the .addFlags() and .removeFlags() function accept now arbitary words as keywords :

$transporter:=IMAP New transporter($parameters)
$boxInfo:=$transporter.selectBox("INBOX")

$mailIds:=["122";"123";"124"]
// Custom keyword
$keywords:={"myKeyword":true}
// apply the custom keyword to the collection of mail
$status:=$transporter.addFlags($mailIds; $keywords)

and the .selectBox() function returns the list of flags allowed in the current mailbox through the .flags and .permanentFlags attributs:

$selectBox:=$transporter.selectBox("INBOX")
//$selectBox={name:INBOX,
//mailCount:124,
//mailRecent:0,
//id:644737301,
//flags:\\Answered \\Flagged \\Draft \\Deleted \\Seen $NotPhishing $Phishing myKeyword,
//permanentFlags:\\Answered \\Flagged \\Draft \\Deleted \\Seen $NotPhishing $Phishing myKeyword \\*} 

mailbox Id

Because the mailbox name is not sufficient alone to know if the box selected has been renamed or removed and recreated, we add the id to the information returned by the .selectBox() and the .getBoxInfo() function of the IMAP transporter:

$boxInfo:=$transporter.getBoxInfo("INBOX")
//{name:INBOX,
//mailCount:125,
//mailRecent:0,
//id:644737301}

Check out these features with the documentation for more details!

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.