Sample code for 30+ languages & platforms
Lianja

Upload .eml File to an IMAP Mailbox

See more IMAP Examples

Demonstrates how to upload the MIME source of an email to a mailbox on an IMAP server.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loImap = createobject("CkImap")

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

// Connect to an IMAP server.
// Use TLS
loImap.Ssl = .T.
loImap.Port = 993
llSuccess = loImap.Connect("MY-IMAP-DOMAIN")
if (llSuccess <> .T.) then
    ? loImap.LastErrorText
    release loImap
    return
endif

// Login
llSuccess = loImap.Login("MY-IMAP-LOGIN","MY-IMAP-PASSWORD")
if (llSuccess <> .T.) then
    ? loImap.LastErrorText
    release loImap
    return
endif

loSbMime = createobject("CkStringBuilder")
loSbMime.LoadFile("qa_data/eml/emoji_pizza.eml","utf-8")

// Upload to the mailbox.
llSuccess = loImap.AppendMime("[Gmail]/testFolder",loSbMime.GetAsString())
if (llSuccess <> .T.) then
    ? loImap.LastErrorText
    release loImap
    release loSbMime
    return
endif

loImap.Disconnect()

? "OK."


release loImap
release loSbMime