Sample code for 30+ languages & platforms
Visual FoxPro

Subscribe to an IMAP Mailbox

See more IMAP Examples

Demonstrates the Chilkat Imap.Subscribe method, which subscribes the authenticated IMAP account to a mailbox. Subscription controls which mailboxes are returned by subscribed-mailbox listings. This example subscribes to a mailbox.

Background: An account can have many mailboxes, but a user often cares about only some of them. IMAP's subscription list is that curated set: mail clients typically show subscribed folders by default and hide the rest. Subscribing does not create or change a mailbox — it only adds it to the "show me this one" list (retrieved with a subscribed-only listing). Unsubscribe removes it from that list.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loImap

lnSuccess = 0

*  Demonstrates the Imap.Subscribe method, which subscribes the authenticated IMAP account to
*  a mailbox.  Subscription controls which mailboxes are returned by subscribed-mailbox
*  listings.

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

*  Subscribe to a mailbox.
lnSuccess = loImap.Subscribe("Archive2026")
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

? "Subscribed to the mailbox."

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

RELEASE loImap