Internet Direct (Indy) Version 9.0.1 Beta
TIdMessageDecoderMIME.ReadBody
Decodes the contents of a MIME-encode message part.

function ReadBody(ADestStream: TStream; var AMsgEnd: Boolean): TIdMessageDecoder; override;
Parameters
ADestStream: TStream
Stream to receive the decode message part contents.

var AMsgEnd: Boolean
Returns
TIdMessageDecoder - Decoder used for the message part, or Nil.

Description
ReadBody is a TIdMessageDecoder function that is used to convert the MIME-encoded contents of an RFC message part to its textual representation.

ReadBody examines the message part type to determine the TIdMessageDecoder used for the encoded message part. ReadBody returns the TIdMessageDecoder instance to be used for the message part, or Nil when the message part is not an encoded attachment. When an attachment is detected, the content-transfer-encoding header is used to determine the proper decoder based on the following values of the header:

When the content-transfer-encoding does not match the preceeding values, an EIdException will be raised with the constant message RSMessageCoderMIMEUnrecognizedContentTrasnferEncoding and the value for the message header.

ReadBody reads the message part content, on line at a time, using ReadLn. If a MIMEBoundary is detected in the line, a new TIdMessageDecoderMIME instance is created for the new message part, and the method is exited. ReadBody used the message decoder, when present, to convert the encoded data using TIdMessageDecoder.DecodeToStream. Decoded message part contents are written to ADestStream until a blank line is read from the encoded message part.