Skip to main content

Encoding

property Encoding: TIdMessageEncoding read write;

Example

procedure SelectMimeLayout;
var
Msg: TIdMessage;
begin
Msg := Email;
if Msg = nil then Exit;

Msg.Encoding := meMIME;
end;

Usage

Encoding selects the message layout as automatic, MIME or legacy plain-text-with-attachments and also overwrites the attachment encoder preference.

Additional Technical Info

Encoding selects message layout, not character encoding and not Content-Transfer-Encoding. Its TIdMessageEncoding values are:

  • meDefault - defer the layout decision until header generation;
  • meMIME - generate MIME headers, boundaries and parts; and
  • mePlainText - write Body followed by optional legacy UUE/XXE-style attachments/text blocks.

Assignment first stores the enum and then overwrites AttachmentEncoding: meMIME selects MIME; both other values select UUE. Set any intentional attachment override after setting Encoding. Encoder registry lookup can raise; because the enum field is stored first, a missing registry entry can leave Encoding changed even though assignment failed.

GenerateHeader permanently resolves meDefault: zero MessageParts becomes mePlainText; any part—including a text part—becomes meMIME. The setter side effect runs again during that resolution. Generation also normalizes part transfer values, content type and boundaries; reading Encoding afterwards returns the resolved value rather than meDefault.

ProcessHeaders chooses only from raw MIME-Version: absent means mePlainText, present means meMIME. It does not infer MIME from a boundary, Content-Type or transfer encoding, and the setter again changes AttachmentEncoding. Changing Encoding after a load does not reparse Body/parts.

With NoEncode, normal layout processing is bypassed and this property has no output effect. Use MIME for ordinary structured messages; legacy plain-text attachment layout is compatibility behavior rather than a modern interoperability default.

The example changes state only and was source-reviewed, not executed or sent.

External references

Created 2026-07-15