Sample code for 30+ languages & platforms
Visual FoxPro

Unsubscribe from an IMAP Mailbox

See more IMAP Examples

Demonstrates the Chilkat Imap.Unsubscribe method, which removes the subscription to a mailbox. The mailbox itself and its messages are not deleted. This example unsubscribes from a mailbox.

Background: Unsubscribing simply drops a mailbox from the account's subscription list, so clients that show only subscribed folders will stop displaying it — the folder and everything in it remain on the server untouched. This is the counterpart to Subscribe, and is how you declutter a mailbox listing without deleting anything (deleting a folder is DeleteMailbox).

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loImap

lnSuccess = 0

*  Demonstrates the Imap.Unsubscribe method, which removes the subscription to a mailbox.
*  The mailbox itself and its messages are not deleted.

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

*  Remove the subscription to a mailbox (the mailbox is not deleted).
lnSuccess = loImap.Unsubscribe("Archive2026")
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

? "Unsubscribed from the mailbox."

lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

RELEASE loImap