Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oImap
LOCAL oSbMime

nSuccess := 0

oImap := CreateObject("Chilkat.Imap")

//  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
oImap:Ssl := 1
oImap:Port := 993
nSuccess := oImap:Connect("MY-IMAP-DOMAIN")
IF (nSuccess != 1)
    ? oImap:LastErrorText
    oImap:destroy()
    RETURN
ENDIF

//  Login
nSuccess := oImap:Login("MY-IMAP-LOGIN", "MY-IMAP-PASSWORD")
IF (nSuccess != 1)
    ? oImap:LastErrorText
    oImap:destroy()
    RETURN
ENDIF

oSbMime := CreateObject("Chilkat.StringBuilder")
oSbMime:LoadFile("qa_data/eml/emoji_pizza.eml", "utf-8")

//  Upload to the mailbox.
nSuccess := oImap:AppendMime("[Gmail]/testFolder", oSbMime:GetAsString())
IF (nSuccess != 1)
    ? oImap:LastErrorText
    oImap:destroy()
    oSbMime:destroy()
    RETURN
ENDIF

oImap:Disconnect()

? "OK."

oImap:destroy()
oSbMime:destroy()