Indy 9
TIdMessageDecoderMIME
Hierarchy, Properties, Methods, Events, See Also, Unit: IdMessageCoderMIME
Implements a decoder for RFC-822 MIME message parts.
TIdMessageDecoderMIME = class(TIdMessageDecoder)
Unit
IdMessageCoderMIME
Description
TIdMessageDecoderMIME is a TIdMessageDecoder descendant that extends the ancestor class to implement a decoder for RFC-822 MIME message parts. TIdMessageDecoderMIME provides methods and properties used to detect the MIMEBoundary, as well as read the RFC message headers and body in an encoded RFC message part.

TIdMessageDecoderMIME.BodyEncoded
TIdMessageDecoderMIME
Indicates if a message has an encoded body.
property BodyEncoded: Boolean;
Description
BodyEncoded is a Boolean property that indicates if the TIdMessageDecoderMIME instance is owned by a TIdMessage, and has a non-blank value in the TIdMessage.ContentTransferEncoding property for the message that owns the decoder.

BodyEncoded is initialized in the Create constructor, and may contain False when the TIdMessage has a MIMEBoundary. BodyEncoded is also used in ReadHeader and ReadBody methods to determine if the ContentTransferEncoding, ContentType, and ContentDisposition values are read from mesasage headers or the acutal body of the message.


TIdMessageDecoderMIME.MIMEBoundary
TIdMessageDecoderMIME, See Also
Represents the boundary marker for a MIME-encoded RFC-822 message part.
property MIMEBoundary: string;
Description
MIMEBoundary is a String property that represents the boundary marker for a MIME-encoded RFC-822 message part. MIMEBoundary is updated by the Create Constructor when the owner of the decoder class instance is a TIdMessage. The TIdMessage.MIMEBoundary property is used as the value of the MIMEBoundary for the decoder class.

TIdMessageDecoderMIME.Create
TIdMessageDecoderMIME, See Also
Constructor for the object instance.
constructor Create(AOwner: TComponent); overload; reintroduce;
constructor Create(AOwner: TComponent; ALine: string); overload; reintroduce;
Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create is the Constructor for the object instance, and relies on the inherited Create method. When AOwner is a TIdMessage instance, Create sets the MIMEBoundary for the decoder to the MIMEBoundary in the TIdMessage that owns the decoder class instance.

TIdMessageDecoderMIME.Create
TIdMessageDecoderMIME, See Also
Constructor for the object instance.
constructor Create(AOwner: TComponent); overload; reintroduce;
constructor Create(AOwner: TComponent; ALine: string); overload; reintroduce;
Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create is the Constructor for the object instance, and relies on the inherited Create method. When AOwner is a TIdMessage instance, Create sets the MIMEBoundary for the decoder to the MIMEBoundary in the TIdMessage that owns the decoder class instance.

TIdMessageDecoderMIME.ReadBody
TIdMessageDecoderMIME, See Also
Decodes the contents of a MIME-encode message part.
function ReadBody(ADestStream: TStream; var VMsgEnd: Boolean): TIdMessageDecoder; override;
Parameters
ADestStream: TStream
Stream to receive the decode message part contents.
Return Value
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. Decoded message part contents are written to ADestStream until a blank line is read from the encoded message part.


TIdMessageDecoderMIME.ReadHeader
TIdMessageDecoderMIME, See Also
Implements the method used to read an RFC message header from a MIME-encoded message part.
procedure ReadHeader; override;
Description
ReadHeader is an overridden procedure in TIdMessageDecoderMIME that implements the method used to read an RFC-822 compliant message header from a MIME-encoded message part.

When BodyEncoded is True, ReadHeader will read header values from the message using the Content-Type and Content-Disposition headers to determine the PartType, ContentType, ContentDisposition, and Filename (for an attachment).

When BodyEncoded is False, ReadHeader calls ReadLn to retrieve lines from the message part until a blank line, that signals the end of message headers, is retrieved. Message headers are added to the Headers property, with folded header lines being added to the most recent message header.

When ReadHeader has retrieved all message header line, the content-disposition header is examined to determine if the message part contains an attachment.

ReadHeader will update the message part type to ptText when an attachment is not found. When an attachment is indicated in the content-disposition message header, ReadHeader sets the message part type to ptAttachment and parses an optional filename into the Filename property.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.