Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
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 DLL Downloads
var
success: Boolean;
original: HCkEmail;
email: HCkEmail;
begin
success := False;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
original := CkEmail_Create();
success := CkEmail_LoadEml(original,'message.eml');
if (success <> True) then
begin
Memo1.Lines.Add(CkEmail__lastErrorText(original));
Exit;
end;
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,'Forwarded message');
CkEmail_putBody(email,'The original email is attached.');
success := CkEmail_AttachEmail(email,original);
if (success <> True) then
begin
Memo1.Lines.Add(CkEmail__lastErrorText(email));
Exit;
end;
success := CkEmail_SaveEml(email,'forward-as-attachment.eml');
if (success <> True) then
begin
Memo1.Lines.Add(CkEmail__lastErrorText(email));
Exit;
end;
Memo1.Lines.Add('Saved forward-as-attachment.eml.');
CkEmail_Dispose(original);
CkEmail_Dispose(email);