Lazarus Pascal Requires Chilkat v11.0.0+
Lazarus Pascal
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 Lazarus Pascal Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Email,
Chilkat.CkDateTime;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
email: TEmail;
now: TCkDateTime;
begin
success := False;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := TEmail.Create;
success := email.LoadEml('message.eml');
if (success <> True) then
begin
WriteLn(email.LastErrorText);
Exit;
end;
WriteLn('Previous Date: ' + email.EmailDateStr);
now := TCkDateTime.Create;
success := now.SetFromCurrentSystemTime();
if (success <> True) then
begin
WriteLn('Failed: now.SetFromCurrentSystemTime.');
Exit;
end;
success := email.SetDt(now);
if (success <> True) then
begin
WriteLn(email.LastErrorText);
Exit;
end;
WriteLn('Updated Date: ' + email.EmailDateStr);
success := email.SaveEml('updated-draft.eml');
if (success <> True) then
begin
WriteLn(email.LastErrorText);
Exit;
end;
WriteLn('Saved updated-draft.eml.');
email.Free;
now.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.