Skip to main content

meDefault

meDefault = 0

Example

procedure ConfigureAutomaticLayout(Message: TIdMessage);
begin
Message.Encoding := meDefault;

{ Add Body and MessageParts before the message is sent or saved. }
end;

Usage

meDefault defers a Velox mail message's whole-message layout choice until header generation examines its message parts.

Additional Technical Info

meDefault is the automatic member of TIdMessageEncoding. It defers the choice between MIME and non-MIME layout until TIdMessage.GenerateHeader counts the message parts.

Despite the property name, this is not a character encoding and does not select UTF-8, base64 or quoted-printable. The example is source-reviewed and is not executed by the documentation workflow.

Automatic selection

Immediately before output, header generation permanently resolves the value:

MessageParts.CountResolved Encoding
0mePlainText
1 or moremeMIME

Any part triggers MIME, including a text part. The property setter runs during resolution, so it also changes AttachmentEncoding. Reading Encoding after generation returns the resolved member, not meDefault; adding or removing parts later does not restore automatic mode.

Assignment side effect

Assigning Message.Encoding := meDefault first stores the enum and then sets AttachmentEncoding to UUE, because the setter treats every non-meMIME value as the legacy plain-layout default. If parts exist when headers are generated, the later resolution to meMIME changes attachment encoding again to MIME.

Set an intentional attachment-encoder override after setting Encoding. Encoder registry lookup can raise after the enum field has already changed, leaving partially updated state.

Construction, clearing and reuse

New messages and ClearHeader set the internal field to meDefault directly. That direct assignment bypasses the property setter. In particular, clearing a reused message can show Encoding = meDefault while retaining a previous AttachmentEncoding value. Reset both properties explicitly when object reuse must reproduce new-message defaults.

Header-generation mutations

Automatic resolution is only one of several mutations performed by header generation. Depending on the selected layout it can also normalize part transfer encodings, clear an incompatible whole-body transfer encoding, infer ContentType, regenerate MIME boundaries and update single-part MIME state. Do not treat sending or saving as serialization of an otherwise unchanged object.

Input behavior

Received messages never resolve to meDefault. ProcessHeaders chooses mePlainText when the raw MIME-Version header is absent and meMIME when it is present. It does not infer the automatic state from parts, boundary, content type or transfer encoding.

Errors and side effects

The constant itself does not raise. Assigning it can fail while selecting the UUE attachment encoder. Later generation can fail in header, charset, part or encoder processing after mutating message state.

Performance and concurrency

Reading the enum is constant-time, but resolving it occurs during a stateful full header/part preparation pass. Do not generate, send, save or mutate one TIdMessage concurrently.

When to use it

Use meDefault when the final part collection is known before output and Indy's simple zero-parts/has-parts decision is appropriate. Choose meMIME explicitly for modern multipart, alternative-body or attachment messages. Avoid relying on automatic mePlainText when legacy UUE output is not acceptable.

Related entries

External references

Created 2026-07-15