Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loImap
lnSuccess = 0
* 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('Chilkat.Imap')
loImap.Ssl = 1
loImap.Port = 993
lnSuccess = loImap.Connect("imap.example.com")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
lnSuccess = loImap.Login("user@example.com","myPassword")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
* Delete a mailbox (folder) from the server.
lnSuccess = loImap.DeleteMailbox("OldFolder")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
? "Mailbox deleted."
lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
RELEASE loImap