Tech Tip: Email ID's Change After Moving to Another Box
PRODUCT: 4D | VERSION: 18 R | PLATFORM: Mac & Win
Published On: December 1, 2020
v18R5 introduced the IMAP transporter object. The IMAP transporter functions are extremely helpful to use when managing emails from an IMAP server in 4D. Moving, copying, and deleting emails can all be accomplished using the IMAP transporter functions. However, it is important to keep in mind that an email's ID changes when they are moved to other mail boxes on the IMAP server. This pertains to the moved or copied version of an email.
Get a test email from Inbox:
var $transporter : 4D.IMAPTransporter $server:=New object $server.host:="{Host.com}" $server.port:="587" $server.user:="{Username}" $server.password:="{Password}" $transporter:=IMAP New transporter($server) $box:=$transporter.selectBox("Inbox") $email:=$transporter.getMail($box.mailCount) |
An test email with ID 18373 is retrieved from the Inbox
Move the test Email to another mail box:
$mailToMove_c:=New collection $mailToMove_c.push($email.id) $statusMove:=$transporter.move($mailToMove_c; "Star") |
Get the moved mail in the other box:
$box:=$transporter.selectBox("Star") $email:=$transporter.getMail($box.mailCount) |
The moved test email in the other box now has ID 101: