Sample code for 30+ languages & platforms
Visual FoxPro

Upload (Append) Email to an IMAP Mailbox

Upload / append an email to an IMAP mailbox.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loImap
LOCAL loEmail

lnSuccess = 0

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

loImap = CreateObject('Chilkat.Imap')

*  Connect to an IMAP server.
*  Use TLS
loImap.Ssl = 1
loImap.Port = 993
lnSuccess = loImap.Connect("imap.example.com")
IF (lnSuccess <> 1) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

*  Login
lnSuccess = loImap.Login("myLogin","myPassword")
IF (lnSuccess <> 1) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

loEmail = CreateObject('Chilkat.Email')

*  Load the email from a .eml file.
lnSuccess = loEmail.LoadEml("myEmail.eml")
IF (lnSuccess <> 1) THEN
    ? loEmail.LastErrorText
    RELEASE loImap
    RELEASE loEmail
    CANCEL
ENDIF

lnSuccess = loImap.AppendMail("Inbox",loEmail)
IF (lnSuccess <> 1) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    RELEASE loEmail
    CANCEL
ENDIF

? "Email uploaded to Inbox!"

*  Disconnect from the IMAP server.
lnSuccess = loImap.Disconnect()

RELEASE loImap
RELEASE loEmail