Description | Hierarchy | Fields | Methods | Properties |
type TMimePart = class(TObject)
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.
constructor Create; |
|
destructor Destroy; override; |
|
procedure Assign(Value: TMimePart); |
|
procedure AssignSubParts(Value: TMimePart); |
|
procedure Clear; |
|
procedure DecodePart; |
|
procedure DecodePartHeader; |
|
procedure EncodePart; |
|
procedure EncodePartHeader; |
|
procedure MimeTypeFromExt(Value: string); |
|
function GetSubPartCount: integer; |
|
function GetSubPart(index: integer): TMimePart; |
|
procedure DeleteSubPart(index: integer); |
|
procedure ClearSubParts; |
|
function AddSubPart: TMimePart; |
|
procedure DecomposeParts; |
|
procedure DecomposePartsBinary(AHeader:TStrings; AStx,AEtx:PANSIChar); |
|
procedure ComposeParts; |
|
procedure WalkPart; |
|
function CanSubPart: boolean; |
property Primary: string read FPrimary write SetPrimary; |
|
property Encoding: string read FEncoding write SetEncoding; |
|
property Charset: string read FCharset write SetCharset; |
|
property DefaultCharset: string read FDefaultCharset write FDefaultCharset; |
|
property PrimaryCode: TMimePrimary read FPrimaryCode Write FPrimaryCode; |
|
property EncodingCode: TMimeEncoding read FEncodingCode Write FEncodingCode; |
|
property CharsetCode: TMimeChar read FCharsetCode Write FCharsetCode; |
|
property TargetCharset: TMimeChar read FTargetCharset Write FTargetCharset; |
|
property ConvertCharset: Boolean read FConvertCharset Write FConvertCharset; |
|
property ForcedHTMLConvert: Boolean read FForcedHTMLConvert Write FForcedHTMLConvert; |
|
property Secondary: string read FSecondary Write FSecondary; |
|
property Description: string read FDescription Write FDescription; |
|
property Disposition: string read FDisposition Write FDisposition; |
|
property ContentID: string read FContentID Write FContentID; |
|
property Boundary: string read FBoundary Write FBoundary; |
|
property FileName: string read FFileName Write FFileName; |
|
property Lines: TStringList read FLines; |
|
property PartBody: TStringList read FPartBody; |
|
property Headers: TStringList read FHeaders; |
|
property PrePart: TStringList read FPrePart; |
|
property PostPart: TStringList read FPostPart; |
|
property DecodedLines: TMemoryStream read FDecodedLines; |
|
property SubLevel: integer read FSubLevel write FSubLevel; |
|
property MaxSubLevel: integer read FMaxSubLevel write FMaxSubLevel; |
|
property AttachInside: boolean read FAttachInside; |
|
property OnWalkPart: THookWalkPart read FOnWalkPart write FOnWalkPart; |
|
property MaxLineLength: integer read FMaxLineLength Write FMaxLineLength; |
constructor Create; |
destructor Destroy; override; |
procedure Assign(Value: TMimePart); |
Assign content of another object to this object. (Only this part, not subparts!)
procedure AssignSubParts(Value: TMimePart); |
Assign content of another object to this object. (With all subparts!)
procedure Clear; |
Clear all data values to default values. It also call ClearSubParts.
procedure DecodePart; |
Decode Mime part from Lines to DecodedLines.
procedure DecodePartHeader; |
Parse header lines from Headers property into another properties.
procedure EncodePart; |
Encode mime part from DecodedLines to Lines and build mime headers.
procedure EncodePartHeader; |
Build header lines in Headers property from another properties.
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.
function GetSubPartCount: integer; |
Return number of decomposed subparts. (On this level! Each of this subparts can hold any number of their own nested subparts!)
function GetSubPart(index: integer): TMimePart; |
Get nested subpart object as new TMimePart. For getting maximum possible index you can use GetSubPartCount method.
procedure DeleteSubPart(index: integer); |
delete subpart on given index.
procedure ClearSubParts; |
Clear and destroy all subpart TMimePart objects.
function AddSubPart: TMimePart; |
Add and create new subpart.
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).
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.
procedure ComposeParts; |
This part and all subparts is composed into one MIME message stored in Lines property.
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
function CanSubPart: boolean; |
Return True
when is possible create next subpart. (MaxSubLevel is still not reached)
property Primary: string read FPrimary write SetPrimary; |
Primary Mime type of part. (i.e. 'application') Writing to this property automaticly generate value of PrimaryCode.
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.
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.
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!)
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.
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.
property CharsetCode: TMimeChar read FCharsetCode Write FCharsetCode; |
Decoded charset type. Possible values are defined in synachar unit.
property TargetCharset: TMimeChar read FTargetCharset Write FTargetCharset; |
System charset type. Default value is charset used by default in your operating system.
property ConvertCharset: Boolean read FConvertCharset Write FConvertCharset; |
If True
, then do internal charset translation of part content between CharsetCode and TargetCharset
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
.
property Secondary: string read FSecondary Write FSecondary; |
Secondary Mime type of part. (i.e. 'mixed')
property Description: string read FDescription Write FDescription; |
Description of Mime part.
property Disposition: string read FDisposition Write FDisposition; |
Value of content disposition field. (i.e. 'inline' or 'attachment')
property ContentID: string read FContentID Write FContentID; |
Content ID.
property Boundary: string read FBoundary Write FBoundary; |
Boundary delimiter of multipart Mime part. Used only in multipart part.
property FileName: string read FFileName Write FFileName; |
Filename of file in binary part.
property Lines: TStringList read FLines; |
String list with lines contains mime part (It can be a full message).
property PartBody: TStringList read FPartBody; |
Encoded form of MIME part data.
property Headers: TStringList read FHeaders; |
All header lines of MIME part.
property PrePart: TStringList read FPrePart; |
On multipart this contains part of message between first line of message and first boundary.
property PostPart: TStringList read FPostPart; |
On multipart this contains part of message between last boundary and end of message.
property DecodedLines: TMemoryStream read FDecodedLines; |
Stream with decoded form of budy part.
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.
property MaxSubLevel: integer read FMaxSubLevel write FMaxSubLevel; |
Specify maximum sublevel value for decomposing.
property AttachInside: boolean read FAttachInside; |
When is True
, then this part maybe(!) have included some uuencoded binary data.
property OnWalkPart: THookWalkPart read FOnWalkPart write FOnWalkPart; |
Here you can assign hook procedure for walking through all part and their subparts.
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.