Date
property Date: TDateTime read write;
Example
procedure SetMessageDate;
var
Msg: TIdMessage;
begin
Msg := Email;
if Msg = nil then Exit;
// Store one fixed local time for every later generation of this message.
Msg.Date := Now;
end;
Usage
Stores the message's local date-time or the zero sentinel that makes each normal header generation use the current clock.
Additional Technical Info
Date is the typed, local-time value behind the Internet message Date header. It is a Delphi TDateTime: the whole-number portion counts days and the fractional portion represents time of day.
This property also carries control state. A value of exactly 0 means “use the current time later” and makes UseNowForDate read True. Any nonzero value makes UseNowForDate read False. Assigning Date therefore changes UseNowForDate without calling its setter.
Header generation
Normal GenerateHeader behavior is:
- If Date is zero, read
Nowinto a temporary value. - Otherwise use the stored Date.
- Format that value as the generated
Dateheader.
The zero case does not write the temporary value back. Repeated generation, sending or saving can therefore produce different Date headers while Date remains zero. Set UseNowForDate to False or assign a nonzero Date when retries, signatures, comparisons or archived output require one stable timestamp.
The formatter expects a local value. It writes the local clock fields and appends the Velox process's current UTC offset; it does not receive Date when obtaining that offset. A stored historical or future value across daylight-saving boundaries can therefore be labelled with the current offset rather than the offset that applied at the represented instant. Generate as close to the intended time as practical, or inspect the generated header where exact historical offset fidelity matters.
Parsing and lifecycle
ProcessHeaders parses the raw Date field, applies its explicit wire offset and converts the result to local time. A missing or unparseable field produces the Indy's zero result, which also enables UseNowForDate. Consequently, loading a message without a usable Date can later generate a new current Date if that message is saved normally.
ClearHeader and Clear set Date to zero. No range, business-calendar or plausibility validation occurs when a script assigns the property. Negative values and dates outside practical mail ranges reach lower date-formatting routines and can format unexpectedly or fail there.
NoEncode bypasses normal generation, so changing Date does not change raw output until normal generation is restored. Date represents message authorship time, not SMTP delivery time, receipt time or IMAP internal date.
The example is source-reviewed only; no message was generated.
External references
- Indy upstream:
TIdMessagedate parsing and generation - implementation used by the Velox-modified class. - Embarcadero:
TDateTime- Delphi representation and range. - Embarcadero:
Now- current local date-time source. - Free Pascal:
TDateTimeand Free Pascal:Now- compatible core type and clock routine. - RFC 5322 section 3.6.1 - origination date semantics and syntax.