Delphi ActiveX Requires Chilkat v11.0.0+
Delphi ActiveX
Forward an email as an attachment
See more Email Object Examples
Attach the original Email to a new message as a message/rfc822 part. The recipient can open the attached email and read its original headers and body.
Chilkat Delphi ActiveX Downloads
var
success: Integer;
original: TChilkatEmail;
email: TChilkatEmail;
begin
success := 0;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
original := TChilkatEmail.Create(Self);
success := original.LoadEml('message.eml');
if (success <> 1) then
begin
Memo1.Lines.Add(original.LastErrorText);
Exit;
end;
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 := 'Forwarded message';
email.Body := 'The original email is attached.';
success := email.AttachEmail(original.ControlInterface);
if (success <> 1) then
begin
Memo1.Lines.Add(email.LastErrorText);
Exit;
end;
success := email.SaveEml('forward-as-attachment.eml');
if (success <> 1) then
begin
Memo1.Lines.Add(email.LastErrorText);
Exit;
end;
Memo1.Lines.Add('Saved forward-as-attachment.eml.');