# Class TMimePart

Description | Hierarchy | Fields | Methods | Properties

## Unit

mimepart

## 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

TMimePart > TObject

## Methods

### Overview

| `constructor Create;`
| `destructor Destroy; override;`
| `function AddSubPart: TMimePart;`
| `procedure Assign(Value: TMimePart);`
| `procedure AssignSubParts(Value: TMimePart);`
| `function CanSubPart: boolean;`
| `procedure Clear;`
| `procedure ClearSubParts;`
| `procedure ComposeParts;`
| `procedure DecodePart;`
| `procedure DecodePartHeader;`
| `procedure DecomposeParts;`
| `procedure DeleteSubPart(index: integer);`
| `procedure EncodePart;`
| `procedure EncodePartHeader;`
| `function GetSubPart(index: integer): TMimePart;`
| `function GetSubPartCount: integer;`
| `procedure MimeTypeFromExt(Value: string);`
| `procedure WalkPart;`

### Description

| `function AddSubPart: TMimePart;`

Add and create new subpart.

| `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!)

| `function CanSubPart: boolean;`

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

| `procedure Clear;`

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

| `procedure ClearSubParts;`

Clear and destroy all subpart TMimePart objects.

| `procedure ComposeParts;`

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

| `constructor Create;`

| `procedure DecodePart;`

Decode Mime part from Lines to DecodedLines.

| `procedure DecodePartHeader;`

Parse header lines from Headers property into another properties.

| `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 DeleteSubPart(index: integer);`

delete subpart on given index.

| `destructor Destroy; override;`

| `procedure EncodePart;`

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

| `procedure EncodePartHeader;`

Build header lines in Headers property from another properties.

| `function GetSubPart(index: integer): TMimePart;`

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

| `function GetSubPartCount: integer;`

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

| `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.

| `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

## Properties

### Overview

| `property AttachInside: boolean;`
| `property Boundary: string;`
| `property Charset: string;`
| `property CharsetCode: TMimeChar;`
| `property ContentID: string;`
| `property DecodedLines: TMemoryStream;`
| `property DefaultCharset: string;`
| `property Description: string;`
| `property Disposition: string;`
| `property Encoding: string;`
| `property EncodingCode: TMimeEncoding;`
| `property FileName: string;`
| `property Headers: TStringList;`
| `property Lines: TStringList;`
| `property MaxLineLength: integer;`
| `property MaxSubLevel: integer;`
| `property OnWalkPart: THookWalkPart;`
| `property PartBody: TStringList;`
| `property PostPart: TStringList;`
| `property PrePart: TStringList;`
| `property Primary: string;`
| `property PrimaryCode: TMimePrimary;`
| `property Secondary: string;`
| `property SubLevel: integer;`
| `property TargetCharset: TMimeChar;`

### Description

| `property AttachInside: boolean;`

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

| `property Boundary: string;`

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

| `property Charset: string;`

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 CharsetCode: TMimeChar;`

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

| `property ContentID: string;`

Content ID.

| `property DecodedLines: TMemoryStream;`

Stream with decoded form of budy part.

| `property DefaultCharset: string;`

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 Description: string;`

Description of Mime part.

| `property Disposition: string;`

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

| `property Encoding: string;`

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

| `property EncodingCode: TMimeEncoding;`

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 FileName: string;`

Filename of file in binary part.

| `property Headers: TStringList;`

All header lines of MIME part.

| `property Lines: TStringList;`

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

| `property MaxLineLength: integer;`

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.

| `property MaxSubLevel: integer;`

Specify maximum sublevel value for decomposing.

| `property OnWalkPart: THookWalkPart;`

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

| `property PartBody: TStringList;`

Encoded form of MIME part data.

| `property PostPart: TStringList;`

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

| `property PrePart: TStringList;`

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

| `property Primary: string;`

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

| `property PrimaryCode: TMimePrimary;`

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

| `property Secondary: string;`

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

| `property SubLevel: integer;`

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

| `property TargetCharset: TMimeChar;`

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

Generated by PasDoc 0.8.8.2 on 2005-01-19 20:01:18