Sample code for 30+ languages & platforms
Lianja

Upload (Append) Email to an IMAP Mailbox

Upload / append an email to an IMAP mailbox.

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")

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

// Login
llSuccess = loImap.Login("myLogin","myPassword")
if (llSuccess <> .T.) then
    ? loImap.LastErrorText
    release loImap
    return
endif

loEmail = createobject("CkEmail")

// Load the email from a .eml file.
llSuccess = loEmail.LoadEml("myEmail.eml")
if (llSuccess <> .T.) then
    ? loEmail.LastErrorText
    release loImap
    release loEmail
    return
endif

llSuccess = loImap.AppendMail("Inbox",loEmail)
if (llSuccess <> .T.) then
    ? loImap.LastErrorText
    release loImap
    release loEmail
    return
endif

? "Email uploaded to Inbox!"

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


release loImap
release loEmail