B4X Requires Chilkat v11.0.0+
B4X
Read text and binary MIME parts by content type
See more Email Object Examples
Use the same wildcard and inclusion flags for both counting and retrieval. Request decoded text for textual parts and BinData for binary parts. Use GetAttachedEmail when the goal is to inspect a nested email as a message.
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("workshop.eml")
If success <> True Then
Log(email.LastErrorText)
Return
End If
Dim types As String = "*/*"
Dim inlineOnly As Boolean = False
Dim excludeAttachments As Boolean = False
Dim count As Int = email.GetNumPartsOfType(types, inlineOnly, excludeAttachments)
Dim mediaType As ChilkatStringBuilder
mediaType.Initialize
Dim i As Int = 0
Do While (i < count)
mediaType.SetString(email.GetNthContentType(i, types, inlineOnly, excludeAttachments))
If mediaType.StartsWith("text/", False) = True Then
Dim partText As String = email.GetNthTextPartOfType(i, types, inlineOnly, excludeAttachments)
If email.LastMethodSuccess <> True Then
Log(email.LastErrorText)
Return
End If
Log(mediaType.GetAsString & " " & partText)
Else
Dim data As ChilkatBinData
data.Initialize
success = email.GetNthBinaryPartOfTypeBd(i, types, inlineOnly, excludeAttachments, data)
If success <> True Then
Log(email.LastErrorText)
Return
End If
Log(mediaType.GetAsString & " " & data.NumBytes & " bytes")
End If
i = i + 1
Loop