Python Requires Chilkat v11.0.0+
Python
Forward an email as an attachment
See more Email Object Examples
Attach the original Email to a new message as a message/rfc822 part. The recipient can open the attached email and read its original headers and body.
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 = "Sam Lee <sam@example.com>"
success = email.AddTo("Alex Rivera","alex@example.net")
if (success != True):
print(email.LastErrorText)
sys.exit()
email.Subject = "Forwarded message"
email.Body = "The original email is attached."
success = email.AttachEmail(original)
if (success != True):
print(email.LastErrorText)
sys.exit()
success = email.SaveEml("forward-as-attachment.eml")
if (success != True):
print(email.LastErrorText)
sys.exit()
print("Saved forward-as-attachment.eml.")