Lianja
Lianja
Delete an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.DeleteMailbox method, which deletes a mailbox from the IMAP server. This deletes the mailbox itself, not merely the messages it contains. This example deletes a mailbox named OldFolder.
Background: Deleting a mailbox removes the folder and everything in it — an irreversible action, so applications typically confirm first. Server rules can add constraints: some refuse to delete a folder that still has child folders, or that is currently selected. This is the counterpart to
CreateMailbox; to remove individual messages rather than a whole folder, mark them deleted and Expunge.Chilkat Lianja Downloads
llSuccess = .F.
// Demonstrates the Imap.DeleteMailbox method, which deletes a mailbox from the IMAP server.
// This deletes the mailbox itself, not merely the messages it contains.
loImap = createobject("CkImap")
loImap.Ssl = .T.
loImap.Port = 993
llSuccess = loImap.Connect("imap.example.com")
if (llSuccess = .F.) then
? loImap.LastErrorText
release loImap
return
endif
llSuccess = loImap.Login("user@example.com","myPassword")
if (llSuccess = .F.) then
? loImap.LastErrorText
release loImap
return
endif
// Delete a mailbox (folder) from the server.
llSuccess = loImap.DeleteMailbox("OldFolder")
if (llSuccess = .F.) then
? loImap.LastErrorText
release loImap
return
endif
? "Mailbox deleted."
llSuccess = loImap.Disconnect()
if (llSuccess = .F.) then
? loImap.LastErrorText
release loImap
return
endif
release loImap