Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
MIME CurrentDateTime Property
See more MIME Examples
Demonstrates the read-only CurrentDateTime property, which returns the current local date and time formatted as an Internet message date including the numeric UTC offset. The example uses it to populate a Date header field.
Background. Internet message dates follow the RFC 5322 format, for example
Fri, 21 Nov 1997 09:55:06 -0600. CurrentDateTime produces a value in that form for use in message headers.Chilkat Pascal (Lazarus/Delphi) 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.Mime;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
mime: TMime;
now: string;
head: string;
begin
success := False;
mime := TMime.Create;
success := mime.SetBodyFromPlainText('Message with a Date header.');
if (success = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
// CurrentDateTime returns the current local date and time formatted as an Internet message date,
// including the numeric UTC offset, for example: Fri, 21 Nov 1997 09:55:06 -0600
now := mime.CurrentDateTime;
WriteLn('Current date/time: ' + now);
// It can be used to populate a Date header field.
mime.SetHeaderField('Date',now);
head := mime.GetEntireHead();
if (mime.LastMethodSuccess = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
WriteLn(head);
mime.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.