Sample code for 30+ languages & platforms
Delphi ActiveX Requires Chilkat v11.0.0+

Update the Date of a saved draft

See more Email Object Examples

New Email objects already have a Date field. When reusing a saved draft, set its Date from the system clock immediately before submission. Save a separate copy so the original date is still available.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
var
success: Integer;
email: TChilkatEmail;
now: TCkDateTime;

begin
success := 0;

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

email := TChilkatEmail.Create(Self);
success := email.LoadEml('message.eml');
if (success <> 1) then
  begin
    Memo1.Lines.Add(email.LastErrorText);
    Exit;
  end;
Memo1.Lines.Add('Previous Date: ' + email.EmailDateStr);
now := TCkDateTime.Create(Self);
success := now.SetFromCurrentSystemTime();
if (success <> 1) then
  begin
    Memo1.Lines.Add('Failed: now.SetFromCurrentSystemTime.');
    Exit;
  end;
success := email.SetDt(now.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(email.LastErrorText);
    Exit;
  end;
Memo1.Lines.Add('Updated Date: ' + email.EmailDateStr);

success := email.SaveEml('updated-draft.eml');
if (success <> 1) then
  begin
    Memo1.Lines.Add(email.LastErrorText);
    Exit;
  end;
Memo1.Lines.Add('Saved updated-draft.eml.');