B4X Requires Chilkat v11.0.0+
B4X
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 B4X Downloads
Dim success As Boolean = False
' Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim email As ChilkatEmail
email.Initialize
success = email.LoadEml("with-attachments.eml")
If success <> True Then
Log(email.LastErrorText)
Return
End If
Log("From: " & email.From)
Log("Subject: " & email.Subject)
Log("Date: " & email.EmailDateStr)
Dim i As Int = 0
Do While (i < email.NumTo)
Log("To: " & email.GetToName(i) & " " & email.GetToAddr(i))
i = i + 1
Loop
Dim referenceId As String = email.GetHeaderField("X-Reference-ID")
If email.LastMethodSuccess = True Then
Log("Reference: " & referenceId)
End If
If email.HasPlainTextBody = True Then
Log(email.GetPlainTextBody)
Else
If email.HasHtmlBody = True Then
Dim reader As ChilkatHtmlToText
reader.Initialize
Log(reader.ToText(email.GetHtmlBody))
Else
Log("No text or HTML body.")
End If
End If