Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

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

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

//  Remove the subscription to a mailbox (the mailbox is not deleted).
llSuccess = loImap.Unsubscribe("Archive2026")
if (llSuccess = .F.) then
    ? loImap.LastErrorText
    release loImap
    return
endif

? "Unsubscribed from the mailbox."

llSuccess = loImap.Disconnect()
if (llSuccess = .F.) then
    ? loImap.LastErrorText
    release loImap
    return
endif



release loImap