Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
Create, save, and reopen a plain-text email
See more Email Object Examples
Set the sender, recipient, subject, and plain-text body. Save the result as an EML file, then open it in a second Email object and read its contents.
Chilkat Delphi DLL Downloads
var
success: Boolean;
email: HCkEmail;
received: HCkEmail;
begin
success := False;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := CkEmail_Create();
CkEmail_putFrom(email,'Sam Lee <sam@example.com>');
success := CkEmail_AddTo(email,'Alex Rivera','alex@example.net');
if (success <> True) then
begin
Memo1.Lines.Add(CkEmail__lastErrorText(email));
Exit;
end;
CkEmail_putSubject(email,'Hello');
CkEmail_putBody(email,'This is a plain-text message.');
success := CkEmail_SaveEml(email,'message.eml');
if (success <> True) then
begin
Memo1.Lines.Add(CkEmail__lastErrorText(email));
Exit;
end;
received := CkEmail_Create();
success := CkEmail_LoadEml(received,'message.eml');
if (success <> True) then
begin
Memo1.Lines.Add(CkEmail__lastErrorText(received));
Exit;
end;
Memo1.Lines.Add(CkEmail__from(received));
Memo1.Lines.Add(CkEmail__subject(received));
Memo1.Lines.Add(CkEmail__getPlainTextBody(received));
CkEmail_Dispose(email);
CkEmail_Dispose(received);