Visual FoxPro Requires Chilkat v11.0.0+
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loEmail
LOCAL lcTypes
LOCAL lnInlineOnly
LOCAL lnExcludeAttachments
LOCAL lnCount
LOCAL loMediaType
LOCAL i
LOCAL lcPartText
LOCAL loData
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
loEmail = CreateObject('Chilkat.Email')
lnSuccess = loEmail.LoadEml("workshop.eml")
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
lcTypes = "*/*"
lnInlineOnly = 0
lnExcludeAttachments = 0
lnCount = loEmail.GetNumPartsOfType(lcTypes,lnInlineOnly,lnExcludeAttachments)
loMediaType = CreateObject('Chilkat.StringBuilder')
i = 0
DO WHILE (i < lnCount)
loMediaType.SetString(loEmail.GetNthContentType(i,lcTypes,lnInlineOnly,lnExcludeAttachments))
IF (loMediaType.StartsWith("text/",0) = 1) THEN
lcPartText = loEmail.GetNthTextPartOfType(i,lcTypes,lnInlineOnly,lnExcludeAttachments)
IF (loEmail.LastMethodSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
RELEASE loMediaType
CANCEL
ENDIF
? loMediaType.GetAsString() + " " + lcPartText
ELSE
loData = CreateObject('Chilkat.BinData')
lnSuccess = loEmail.GetNthBinaryPartOfTypeBd(i,lcTypes,lnInlineOnly,lnExcludeAttachments,loData)
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
RELEASE loMediaType
RELEASE loData
CANCEL
ENDIF
? loMediaType.GetAsString() + " " + STR(loData.NumBytes) + " bytes"
ENDIF
i = i + 1
ENDDO
RELEASE loEmail
RELEASE loMediaType
RELEASE loData