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

Create an email with plain-text and HTML bodies

See more Email Object Examples

Set the From and Reply-To addresses, add a recipient, and provide plain-text and HTML versions of the same body. Save the message as text-and-html.eml.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
email: HCkEmail;

begin
success := False;

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

email := CkEmail_Create();
CkEmail_putFromName(email,'Sam Lee');
CkEmail_putFromAddress(email,'sam@example.com');
CkEmail_putReplyTo(email,'replies@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,'Sample message');
CkEmail_putCharset(email,'utf-8');
//  A custom header can carry a reference alongside the standard message fields.
CkEmail_AddHeaderField(email,'X-Reference-ID','REF-42');
success := CkEmail_AddPlainTextAlternativeBody(email,'Read more at https://example.com/details.');
if (success <> True) then
  begin
    Memo1.Lines.Add(CkEmail__lastErrorText(email));
    Exit;
  end;
success := CkEmail_AddHtmlAlternativeBody(email,'<p><a href=''https://example.com/details''>Read more</a></p>');
if (success <> True) then
  begin
    Memo1.Lines.Add(CkEmail__lastErrorText(email));
    Exit;
  end;

success := CkEmail_SaveEml(email,'text-and-html.eml');
if (success <> True) then
  begin
    Memo1.Lines.Add(CkEmail__lastErrorText(email));
    Exit;
  end;
Memo1.Lines.Add('Saved text-and-html.eml.');

CkEmail_Dispose(email);