Save emails in a specific mailbox

Automatically translated from English

When you send emails from 4D, your customers might expect to get a copy in the “Sent” mailbox displayed by Outlook or Apple Mail. For this, 4D v18 R6 has a new command for you. Say hello to the new IMAP transporter append() function.

HDI IMAP Append

To save an email after sending it, you first need to create two transporters:

  • one SMTP transporter to send your email to your client,
  • and a second IMAP transporter to upload your email onto your server mail.

 

After sending your email with SMTP, use the IMAP transporter append() function:

// SMTP transporter creation
$SMTPTransporter:=SMTP New transporter($SMTPserver)
 
// Send email to the client
$status:=$SMTPTransporter.send($email)
  
// If sending is successful, upload email onto your mail server
If ($status.success)
  // IMAP transporter creation
  $IMAPTransporter:=IMAP New transporter($IMAPserver)
  // Upload email to the "Sent" mailbox
  $status:=$IMAPTransporter.append($email; "Sent")
End if

And that’s it!

Of course, you can use the append() function for other tasks like creating draft emails:

// IMAP transporter creation
$IMAPTransporter:=IMAP New transporter($IMAPserver)
 
// Upload email to the "Drafts" mailbox
$status:=$IMAPTransporter.append($email; "Drafts")

Check out the documentation and the HDI above to learn more about the new features! 

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.