Visual FoxPro Requires Chilkat v11.0.0+
Visual FoxPro
Create an email with plain-text and HTML bodies
See more Email Object Examples
Set the From and Reply-To addresses, add a recipient, and provide plain-text and HTML versions of the same body. Save the message as text-and-html.eml.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loEmail
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
loEmail = CreateObject('Chilkat.Email')
loEmail.FromName = "Sam Lee"
loEmail.FromAddress = "sam@example.com"
loEmail.ReplyTo = "replies@example.com"
lnSuccess = loEmail.AddTo("Alex Rivera","alex@example.net")
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
loEmail.Subject = "Sample message"
loEmail.Charset = "utf-8"
* A custom header can carry a reference alongside the standard message fields.
loEmail.AddHeaderField("X-Reference-ID","REF-42")
lnSuccess = loEmail.AddPlainTextAlternativeBody("Read more at https://example.com/details.")
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
lnSuccess = loEmail.AddHtmlAlternativeBody("<p><a href='https://example.com/details'>Read more</a></p>")
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
lnSuccess = loEmail.SaveEml("text-and-html.eml")
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
? "Saved text-and-html.eml."
RELEASE loEmail