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

Build an AMP email with text and HTML fallbacks

See more Email Object Examples

Place text/x-amp-html inside multipart/alternative, before the regular HTML alternative. Use the AMP email validator and meet your provider’s sender requirements before using a dynamic campaign. AMP email MIME structure.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
var
success: Integer;
email: TChilkatEmail;
mimeBytes: TChilkatBinData;
mime: TChilkatMime;
special: TChilkatMime;
standard: TChilkatMime;

begin
success := 0;

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

email := TChilkatEmail.Create(Self);
email.From := 'Workshop team <events@example.com>';
success := email.AddTo('Alex Rivera','alex@example.net');
if (success <> 1) then
  begin
    Memo1.Lines.Add(email.LastErrorText);
    Exit;
  end;
email.Subject := 'Workshop reminder';
email.Body := 'Your workshop starts at 09:00.';
mimeBytes := TChilkatBinData.Create(Self);
success := email.GetMimeBd(mimeBytes.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(email.LastErrorText);
    Exit;
  end;
mime := TChilkatMime.Create(Self);
success := mime.LoadMimeBd(mimeBytes.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(mime.LastErrorText);
    Exit;
  end;
success := mime.ConvertToMultipartAlt();
if (success <> 1) then
  begin
    Memo1.Lines.Add(mime.LastErrorText);
    Exit;
  end;
//  Append the specialist part before the standard HTML fallback.
special := TChilkatMime.Create(Self);
special.ContentType := 'text/x-amp-html';
special.Charset := 'utf-8';
special.SetBody('<!doctype html><html amp4email><head><meta charset=''utf-8''><style amp4email-boilerplate>body{visibility:hidden}</style><script async src=''https://cdn.ampproject.org/v0.js''></script></head><body><p>Your workshop starts at 09:00.</p></body></html>');
success := mime.AppendPart(special.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(mime.LastErrorText);
    Exit;
  end;
standard := TChilkatMime.Create(Self);
standard.ContentType := 'text/html';
standard.Charset := 'utf-8';
standard.SetBody('<p>Your workshop starts at <b>09:00</b>.</p>');
success := mime.AppendPart(standard.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(mime.LastErrorText);
    Exit;
  end;
success := mime.SaveMime('amp.eml');
if (success <> 1) then
  begin
    Memo1.Lines.Add(mime.LastErrorText);
    Exit;
  end;
Memo1.Lines.Add('Saved amp.eml.');