DataFlex
DataFlex
Copy an IMAP Message to Another Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.Copy method, which copies one message from the currently selected mailbox to a destination mailbox. The first argument identifies the source message; the second (bUid) indicates whether the id is a UID (true) or a sequence number (false). This example copies a message from the Inbox to another mailbox.
Background: Messages can be identified two ways in IMAP: a sequence number (the message's current 1-based position, which shifts as messages are added or expunged) or a UID (a stable identifier that doesn't change). The
bUid flag tells Copy which you're passing. Copying leaves the original in place and places a duplicate in the destination — use MoveMessages to relocate instead of duplicate.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
String sTemp1
Move False To iSuccess
// Demonstrates the Imap.Copy method, which copies one message from the currently selected
// mailbox to a destination mailbox. The 1st argument identifies the source message; the 2nd
// (bUid) indicates whether the id is a UID (True) or a sequence number (False).
Get Create (RefClass(cComChilkatImap)) To hoImap
If (Not(IsComObjectCreated(hoImap))) Begin
Send CreateComObject of hoImap
End
Set ComSsl Of hoImap To True
Set ComPort Of hoImap To 993
Get ComConnect Of hoImap "imap.example.com" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComLogin Of hoImap "user@example.com" "myPassword" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Select the source mailbox.
Get ComSelectMailbox Of hoImap "Inbox" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Copy message sequence number 1 to the "Archive2026" mailbox. bUid = False means the id
// is a sequence number, not a UID.
Get ComCopy Of hoImap 1 False "Archive2026" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Message copied."
Get ComDisconnect Of hoImap To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure