DataFlex
DataFlex
Get the Decoded MIME Body Text
See more MIME Examples
Demonstrates the Chilkat Mime.GetBodyDecoded method, which returns the decoded body as text. It takes no arguments. Chilkat first reverses the Content-Transfer-Encoding and then interprets the bytes according to the declared charset.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: This gives you the actual, human-readable content of a text part — the two-step decode (transfer encoding, then charset) is exactly what a mail client does to display it. Use it for text parts; for binary content such as an image, decode to bytes with
GetBodyBd instead, since forcing binary through a text decode would corrupt it.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMime
String sBodyText
String sTemp1
Boolean bTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get ComLoadMimeFile Of hoMime "qa_data/message.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// Return the body as decoded text. Chilkat first reverses the Content-Transfer-Encoding (Base64
// or quoted-printable) and then interprets the bytes according to the declared charset.
Get ComGetBodyDecoded Of hoMime To sBodyText
Get ComLastMethodSuccess Of hoMime To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
Showln sBodyText
End_Procedure