Sample code for 30+ languages & platforms
Visual FoxPro Requires Chilkat v11.0.0+

Create, save, and reopen a plain-text email

See more Email Object Examples

Set the sender, recipient, subject, and plain-text body. Save the result as an EML file, then open it in a second Email object and read its contents.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loEmail
LOCAL loReceived

lnSuccess = 0

*  Assumes Chilkat is unlocked. See Global Unlock Sample.

loEmail = CreateObject('Chilkat.Email')
loEmail.From = "Sam Lee <sam@example.com>"
lnSuccess = loEmail.AddTo("Alex Rivera","alex@example.net")
IF (lnSuccess <> 1) THEN
    ? loEmail.LastErrorText
    RELEASE loEmail
    CANCEL
ENDIF

loEmail.Subject = "Hello"
loEmail.Body = "This is a plain-text message."
lnSuccess = loEmail.SaveEml("message.eml")
IF (lnSuccess <> 1) THEN
    ? loEmail.LastErrorText
    RELEASE loEmail
    CANCEL
ENDIF

loReceived = CreateObject('Chilkat.Email')
lnSuccess = loReceived.LoadEml("message.eml")
IF (lnSuccess <> 1) THEN
    ? loReceived.LastErrorText
    RELEASE loEmail
    RELEASE loReceived
    CANCEL
ENDIF

? loReceived.From
? loReceived.Subject
? loReceived.GetPlainTextBody()

RELEASE loEmail
RELEASE loReceived