Sample code for 30+ languages & platforms
Xbase++ 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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oEmail
LOCAL oReceived

nSuccess := 0

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

oEmail := CreateObject("Chilkat.Email")
oEmail:From := "Sam Lee <sam@example.com>"
nSuccess := oEmail:AddTo("Alex Rivera", "alex@example.net")
IF (nSuccess != 1)
    ? oEmail:LastErrorText
    oEmail:destroy()
    RETURN
ENDIF

oEmail:Subject := "Hello"
oEmail:Body := "This is a plain-text message."
nSuccess := oEmail:SaveEml("message.eml")
IF (nSuccess != 1)
    ? oEmail:LastErrorText
    oEmail:destroy()
    RETURN
ENDIF

oReceived := CreateObject("Chilkat.Email")
nSuccess := oReceived:LoadEml("message.eml")
IF (nSuccess != 1)
    ? oReceived:LastErrorText
    oEmail:destroy()
    oReceived:destroy()
    RETURN
ENDIF

? oReceived:From
? oReceived:Subject
? oReceived:GetPlainTextBody()

oEmail:destroy()
oReceived:destroy()