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.
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!