Delphi ActiveX Requires Chilkat v11.0.0+
Delphi ActiveX
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 ActiveX Downloads
var
success: Integer;
email: TChilkatEmail;
received: TChilkatEmail;
begin
success := 0;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := TChilkatEmail.Create(Self);
email.From := 'Sam Lee <sam@example.com>';
success := email.AddTo('Alex Rivera','alex@example.net');
if (success <> 1) then
begin
Memo1.Lines.Add(email.LastErrorText);
Exit;
end;
email.Subject := 'Hello';
email.Body := 'This is a plain-text message.';
success := email.SaveEml('message.eml');
if (success <> 1) then
begin
Memo1.Lines.Add(email.LastErrorText);
Exit;
end;
received := TChilkatEmail.Create(Self);
success := received.LoadEml('message.eml');
if (success <> 1) then
begin
Memo1.Lines.Add(received.LastErrorText);
Exit;
end;
Memo1.Lines.Add(received.From);
Memo1.Lines.Add(received.Subject);
Memo1.Lines.Add(received.GetPlainTextBody());