Sample code for 30+ languages & platforms
Lianja

Find the "Sent" IMAP Mailbox

See more IMAP Examples

Find the "Sent" IMAP mailbox. Also finds the Junk and Trash mailboxes..

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loImap = createobject("CkImap")

loImap.Ssl = .T.
loImap.Port = 993
llSuccess = loImap.Connect("imap.yourmailserver.com")
if (llSuccess = .F.) then
    ? loImap.LastErrorText
    release loImap
    return
endif

// Login or authenticate in some way..
llSuccess = loImap.Login("your_login","your_password")
if (llSuccess = .F.) then
    ? loImap.LastErrorText
    release loImap
    return
endif

// Get the list of mailboxes.
lcRefName = ""
lcWildcardedMailbox = "*"
llSubscribed = .F.

loMboxes = createobject("CkMailboxes")
llSuccess = loImap.MbxList(llSubscribed,lcRefName,lcWildcardedMailbox,loMboxes)
if (llSuccess = .F.) then
    ? loImap.LastErrorText
    release loImap
    release loMboxes
    return
endif

// The mailbox with the "/Sent" flag is the "Sent" mailbox.
// Likewise for Junk and Trash..
i = 0
do while i < loMboxes.Count
    if (loMboxes.HasFlag(i,"\\Sent") = .T.) then
        ? "Sent mailbox: " + loMboxes.GetName(i)
    endif

    if (loMboxes.HasFlag(i,"\\Junk") = .T.) then
        ? "Junk mailbox: " + loMboxes.GetName(i)
    endif

    if (loMboxes.HasFlag(i,"\\Trash") = .T.) then
        ? "Trash mailbox: " + loMboxes.GetName(i)
    endif

    i = i + 1
enddo

// Disconnect from the IMAP server.
llSuccess = loImap.Disconnect()


release loImap
release loMboxes