Sample code for 30+ languages & platforms
Visual FoxPro

Attach Email as message/rfc822 sub-part to an Email

See more Email Object Examples

Demonstrates how to add attach a message/rfc822 email to another email.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loEmlBytes
LOCAL loFac
LOCAL loEmail
LOCAL loEmailToBeAttached
LOCAL loEmail2
LOCAL loEmlBytes2

lnSuccess = 0

* In this example, we'll attach an email loaded from a .eml file to a new email.

loFac = CreateObject('Chilkat.FileAccess')
loEmlBytes = loFac.ReadEntireFile("qa_data/eml/simple.eml")

loEmail = CreateObject('Chilkat.Email')
loEmail.Subject = "This is a test email with an attached email."
loEmail.Body = "Test with attached email."
loEmail.AddTo("Joe","joe@example.com")
loEmail.From = "mary@example.com"

lnSuccess = loEmail.AttachMessage(loEmlBytes)

? loEmail.GetMime()

* ----------------------------------------------------------------------
* Alternatively, we could do this:
loEmailToBeAttached = CreateObject('Chilkat.Email')
lnSuccess = loEmailToBeAttached.LoadEml("qa_data/eml/simple.eml")

loEmail2 = CreateObject('Chilkat.Email')
loEmail2.Subject = "This is a test email with an attached email."
loEmail2.Body = "Test with attached email."
loEmail2.AddTo("Joe","joe@example.com")
loEmail2.From = "mary@example.com"

loEmlBytes2 = loEmailToBeAttached.GetMimeBinary()
lnSuccess = loEmail2.AttachMessage(loEmlBytes2)

? "----"

? loEmail2.GetMime()

RELEASE loFac
RELEASE loEmail
RELEASE loEmailToBeAttached
RELEASE loEmail2