Python Requires Chilkat v11.0.0+
Python
Attach an existing EML as a message/rfc822 part
See more Email Object Examples
Load the saved message and attach a copy as a nested email. Recipients can open the nested headers, bodies, and attachments. Using an Email object avoids native byte-array differences across languages.
Chilkat Python Downloads
import sys
import chilkat2
success = False
# Assumes Chilkat is unlocked. See Global Unlock Sample.
original = chilkat2.Email()
success = original.LoadEml("message.eml")
if (success != True):
print(original.LastErrorText)
sys.exit()
email = chilkat2.Email()
email.From = "Workshop team <events@example.com>"
success = email.AddTo("Alex Rivera","alex@example.net")
if (success != True):
print(email.LastErrorText)
sys.exit()
email.Subject = "Registration correspondence"
email.Body = "The original message is attached for reference."
success = email.AttachEmail(original)
if (success != True):
print(email.LastErrorText)
sys.exit()
print("Nested messages: " + str(email.NumAttachedMessages))
success = email.SaveEml("correspondence.eml")
if (success != True):
print(email.LastErrorText)
sys.exit()
print("Saved correspondence.eml.")