Class TMimePart

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TMimePart = class(TObject)

Description

Object for working with parts of MIME e-mail.

Each TMimePart object can handle any number of nested subparts as new TMimepart objects. It can handle any tree hierarchy structure of nested MIME subparts itself.

Basic tasks are:

Decoding of MIME message: - store message into Lines property - call DecomposeParts. Now you have decomposed MIME parts in all nested levels! - now you can explore all properties and subparts. (You can use WalkPart method) - if you need decode part, call DecodePart.

Encoding of MIME message:

- if you need multipart message, you must create subpart by AddSubPart. - set all properties of all parts. - set content of part into DecodedLines stream - encode this stream by EncodePart. - compose full message by ComposeParts. (it build full MIME message from all subparts. Do not call this method for each subpart! It is needed on root part!) - encoded MIME message is stored in Lines property.

Hierarchy

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public procedure Assign(Value: TMimePart);
Public procedure AssignSubParts(Value: TMimePart);
Public procedure Clear;
Public procedure DecodePart;
Public procedure DecodePartHeader;
Public procedure EncodePart;
Public procedure EncodePartHeader;
Public procedure MimeTypeFromExt(Value: string);
Public function GetSubPartCount: integer;
Public function GetSubPart(index: integer): TMimePart;
Public procedure DeleteSubPart(index: integer);
Public procedure ClearSubParts;
Public function AddSubPart: TMimePart;
Public procedure DecomposeParts;
Public procedure DecomposePartsBinary(AHeader:TStrings; AStx,AEtx:PANSIChar);
Public procedure ComposeParts;
Public procedure WalkPart;
Public function CanSubPart: boolean;

Properties

Published property Primary: string read FPrimary write SetPrimary;
Published property Encoding: string read FEncoding write SetEncoding;
Published property Charset: string read FCharset write SetCharset;
Published property DefaultCharset: string read FDefaultCharset write FDefaultCharset;
Published property PrimaryCode: TMimePrimary read FPrimaryCode Write FPrimaryCode;
Published property EncodingCode: TMimeEncoding read FEncodingCode Write FEncodingCode;
Published property CharsetCode: TMimeChar read FCharsetCode Write FCharsetCode;
Published property TargetCharset: TMimeChar read FTargetCharset Write FTargetCharset;
Published property ConvertCharset: Boolean read FConvertCharset Write FConvertCharset;
Published property ForcedHTMLConvert: Boolean read FForcedHTMLConvert Write FForcedHTMLConvert;
Published property Secondary: string read FSecondary Write FSecondary;
Published property Description: string read FDescription Write FDescription;
Published property Disposition: string read FDisposition Write FDisposition;
Published property ContentID: string read FContentID Write FContentID;
Published property Boundary: string read FBoundary Write FBoundary;
Published property FileName: string read FFileName Write FFileName;
Published property Lines: TStringList read FLines;
Published property PartBody: TStringList read FPartBody;
Published property Headers: TStringList read FHeaders;
Published property PrePart: TStringList read FPrePart;
Published property PostPart: TStringList read FPostPart;
Published property DecodedLines: TMemoryStream read FDecodedLines;
Published property SubLevel: integer read FSubLevel write FSubLevel;
Published property MaxSubLevel: integer read FMaxSubLevel write FMaxSubLevel;
Published property AttachInside: boolean read FAttachInside;
Published property OnWalkPart: THookWalkPart read FOnWalkPart write FOnWalkPart;
Published property MaxLineLength: integer read FMaxLineLength Write FMaxLineLength;

Description

Methods

Public constructor Create;
 
Public destructor Destroy; override;
 
Public procedure Assign(Value: TMimePart);

Assign content of another object to this object. (Only this part, not subparts!)

Public procedure AssignSubParts(Value: TMimePart);

Assign content of another object to this object. (With all subparts!)

Public procedure Clear;

Clear all data values to default values. It also call ClearSubParts.

Public procedure DecodePart;

Decode Mime part from Lines to DecodedLines.

Public procedure DecodePartHeader;

Parse header lines from Headers property into another properties.

Public procedure EncodePart;

Encode mime part from DecodedLines to Lines and build mime headers.

Public procedure EncodePartHeader;

Build header lines in Headers property from another properties.

Public procedure MimeTypeFromExt(Value: string);

generate primary and secondary mime type from filename extension in value. If type not recognised, it return 'Application/octet-string' type.

Public function GetSubPartCount: integer;

Return number of decomposed subparts. (On this level! Each of this subparts can hold any number of their own nested subparts!)

Public function GetSubPart(index: integer): TMimePart;

Get nested subpart object as new TMimePart. For getting maximum possible index you can use GetSubPartCount method.

Public procedure DeleteSubPart(index: integer);

delete subpart on given index.

Public procedure ClearSubParts;

Clear and destroy all subpart TMimePart objects.

Public function AddSubPart: TMimePart;

Add and create new subpart.

Public procedure DecomposeParts;

E-mail message in Lines property is parsed into this object. E-mail headers are stored in Headers property and is parsed into another properties automaticly. Not need call DecodePartHeader! Content of message (part) is stored into PartBody property. This part is in undecoded form! If you need decode it, then you must call DecodePart method by your hands. Lot of another properties is filled also.

Decoding of parts you must call separately due performance reasons. (Not needed to decode all parts in all reasons.)

For each MIME subpart is created new TMimepart object (accessible via method GetSubPart).

Public procedure DecomposePartsBinary(AHeader:TStrings; AStx,AEtx:PANSIChar);

HTTP message is received by THTTPSend component in two parts: headers are stored in THTTPSend.Headers and a body in memory stream THTTPSend.Document.

On the top of it, HTTP connections are always 8-bit, hence data are transferred in native format i.e. no transfer encoding is applied.

This method operates the similiar way and produces the same result as DecomposeParts.

Public procedure ComposeParts;

This part and all subparts is composed into one MIME message stored in Lines property.

Public procedure WalkPart;

By calling this method is called OnWalkPart event for each part and their subparts. It is very good for calling some code for each part in MIME message

Public function CanSubPart: boolean;

Return True when is possible create next subpart. (MaxSubLevel is still not reached)

Properties

Published property Primary: string read FPrimary write SetPrimary;

Primary Mime type of part. (i.e. 'application') Writing to this property automaticly generate value of PrimaryCode.

Published property Encoding: string read FEncoding write SetEncoding;

String representation of used Mime encoding in part. (i.e. 'base64') Writing to this property automaticly generate value of EncodingCode.

Published property Charset: string read FCharset write SetCharset;

String representation of used Mime charset in part. (i.e. 'iso-8859-1') Writing to this property automaticly generate value of CharsetCode. Charset is used only for text parts.

Published property DefaultCharset: string read FDefaultCharset write FDefaultCharset;

Define default charset for decoding text MIME parts without charset specification. Default value is 'ISO-8859-1' by RCF documents. But Microsoft Outlook use windows codings as default. This property allows properly decode textual parts from some broken versions of Microsoft Outlook. (this is bad software!)

Published property PrimaryCode: TMimePrimary read FPrimaryCode Write FPrimaryCode;

Decoded primary type. Possible values are: MP_TEXT, MP_MULTIPART, MP_MESSAGE and MP_BINARY. If type not recognised, result is MP_BINARY.

Published property EncodingCode: TMimeEncoding read FEncodingCode Write FEncodingCode;

Decoded encoding type. Possible values are: ME_7BIT, ME_8BIT, ME_QUOTED_PRINTABLE and ME_BASE64. If type not recognised, result is ME_7BIT.

Published property CharsetCode: TMimeChar read FCharsetCode Write FCharsetCode;

Decoded charset type. Possible values are defined in synachar unit.

Published property TargetCharset: TMimeChar read FTargetCharset Write FTargetCharset;

System charset type. Default value is charset used by default in your operating system.

Published property ConvertCharset: Boolean read FConvertCharset Write FConvertCharset;

If True, then do internal charset translation of part content between CharsetCode and TargetCharset

Published property ForcedHTMLConvert: Boolean read FForcedHTMLConvert Write FForcedHTMLConvert;

If True, then allways do internal charset translation of HTML parts by MIME even it have their own charset in META tag. Default is False.

Published property Secondary: string read FSecondary Write FSecondary;

Secondary Mime type of part. (i.e. 'mixed')

Published property Description: string read FDescription Write FDescription;

Description of Mime part.

Published property Disposition: string read FDisposition Write FDisposition;

Value of content disposition field. (i.e. 'inline' or 'attachment')

Published property ContentID: string read FContentID Write FContentID;

Content ID.

Published property Boundary: string read FBoundary Write FBoundary;

Boundary delimiter of multipart Mime part. Used only in multipart part.

Published property FileName: string read FFileName Write FFileName;

Filename of file in binary part.

Published property Lines: TStringList read FLines;

String list with lines contains mime part (It can be a full message).

Published property PartBody: TStringList read FPartBody;

Encoded form of MIME part data.

Published property Headers: TStringList read FHeaders;

All header lines of MIME part.

Published property PrePart: TStringList read FPrePart;

On multipart this contains part of message between first line of message and first boundary.

Published property PostPart: TStringList read FPostPart;

On multipart this contains part of message between last boundary and end of message.

Published property DecodedLines: TMemoryStream read FDecodedLines;

Stream with decoded form of budy part.

Published property SubLevel: integer read FSubLevel write FSubLevel;

Show nested level in subpart tree. Value 0 means root part. 1 means subpart from this root. etc.

Published property MaxSubLevel: integer read FMaxSubLevel write FMaxSubLevel;

Specify maximum sublevel value for decomposing.

Published property AttachInside: boolean read FAttachInside;

When is True, then this part maybe(!) have included some uuencoded binary data.

Published property OnWalkPart: THookWalkPart read FOnWalkPart write FOnWalkPart;

Here you can assign hook procedure for walking through all part and their subparts.

Published property MaxLineLength: integer read FMaxLineLength Write FMaxLineLength;

Here you can specify maximum line length for encoding of MIME part. If line is longer, then is splitted by standard of MIME. Correct MIME mailers can de-split this line into original length.


Generated by PasDoc 0.9.0 on 2012-04-23 21:38:57