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

CkPython
import sys
import chilkat

success = False

#  Assumes Chilkat is unlocked. See Global Unlock Sample.

email = chilkat.CkEmail()
email.put_From("Sam Lee <sam@example.com>")
success = email.AddTo("Alex Rivera","alex@example.net")
if (success != True):
    print(email.lastErrorText())
    sys.exit()

email.put_Subject("Hello")
email.put_Body("This is a plain-text message.")
success = email.SaveEml("message.eml")
if (success != True):
    print(email.lastErrorText())
    sys.exit()

received = chilkat.CkEmail()
success = received.LoadEml("message.eml")
if (success != True):
    print(received.lastErrorText())
    sys.exit()

print(received.ck_from())
print(received.subject())
print(received.getPlainTextBody())