Sample code for 30+ languages & platforms
Visual FoxPro Requires Chilkat v11.0.0+

Find the text in an archived T-Mobile gateway email

See more Email Object Examples

Some archived gateway messages carry the SMS text as a related MIME item. Check for an ordinary text body first, then inspect related items by media type. The related-text branch assumes UTF-8, as in the sample format. It reads a saved email and needs no carrier service.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loEmail
LOCAL loMediaType
LOCAL i

lnSuccess = 0

*  Assumes Chilkat is unlocked. See Global Unlock Sample.

loEmail = CreateObject('Chilkat.Email')
lnSuccess = loEmail.LoadEml("gateway.eml")
IF (lnSuccess <> 1) THEN
    ? loEmail.LastErrorText
    RELEASE loEmail
    CANCEL
ENDIF

IF (loEmail.HasPlainTextBody() = 1) THEN
    ? loEmail.GetPlainTextBody()
    RELEASE loEmail
    CANCEL
ENDIF

loMediaType = CreateObject('Chilkat.StringBuilder')
i = 0
DO WHILE (i < loEmail.NumRelatedItems)
    loMediaType.SetString(loEmail.GetRelatedContentType(i))
    IF (loMediaType.ContentsEqual("text/plain",0) = 1) THEN
        ? loEmail.GetRelatedString(i,"utf-8")
        RELEASE loEmail
        RELEASE loMediaType
        CANCEL
    ENDIF

    i = i + 1
ENDDO
? "No text body or related text/plain part."

RELEASE loEmail
RELEASE loMediaType