Xbase++ Requires Chilkat v11.0.0+
Xbase++
Read email headers and display the body as text
See more Email Object Examples
Read the sender, recipients, subject, date, and an optional custom header from an EML file. Display the plain-text body when available, or convert HTML to text. Handle messages that contain neither body format.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oEmail
LOCAL i
LOCAL cReferenceId
LOCAL oReader
nSuccess := 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
oEmail := CreateObject("Chilkat.Email")
nSuccess := oEmail:LoadEml("with-attachments.eml")
IF (nSuccess != 1)
? oEmail:LastErrorText
oEmail:destroy()
RETURN
ENDIF
? "From: " + oEmail:From
? "Subject: " + oEmail:Subject
? "Date: " + oEmail:EmailDateStr
i := 0
DO WHILE (i < oEmail:NumTo)
? "To: " + oEmail:GetToName(i) + " " + oEmail:GetToAddr(i)
i := i + 1
ENDDO
cReferenceId := oEmail:GetHeaderField("X-Reference-ID")
IF (oEmail:LastMethodSuccess == 1)
? "Reference: " + cReferenceId
ENDIF
IF (oEmail:HasPlainTextBody() == 1)
? oEmail:GetPlainTextBody()
ELSE
IF (oEmail:HasHtmlBody() == 1)
oReader := CreateObject("Chilkat.HtmlToText")
? oReader:ToText(oEmail:GetHtmlBody())
ELSE
? "No text or HTML body."
ENDIF
ENDIF
oEmail:destroy()
oReader:destroy()