Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
Read the sender’s Date in UTC and local time
See more Email Object Examples
Parse the Date header from an EML file, then print the same instant in UTC and the current computer’s local zone. Date is the time reported by the sender. For a relay timestamp, use a Received header.
Chilkat Delphi DLL Downloads
var
success: Boolean;
email: HCkEmail;
dateHeader: PWideChar;
when: HCkDateTime;
begin
success := False;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := CkEmail_Create();
success := CkEmail_LoadEml(email,'message.eml');
if (success <> True) then
begin
Memo1.Lines.Add(CkEmail__lastErrorText(email));
Exit;
end;
dateHeader := CkEmail__getHeaderField(email,'Date');
when := CkDateTime_Create();
success := CkDateTime_SetFromRfc822(when,dateHeader);
if (success <> True) then
begin
Memo1.Lines.Add('Failed: when.SetFromRfc822.');
Exit;
end;
Memo1.Lines.Add('Header: ' + dateHeader);
Memo1.Lines.Add('UTC: ' + CkDateTime__getAsTimestamp(when,False));
Memo1.Lines.Add('Local: ' + CkDateTime__getAsTimestamp(when,True));
CkEmail_Dispose(email);
CkDateTime_Dispose(when);