Delphi ActiveX Requires Chilkat v11.0.0+
Delphi ActiveX
Read an attached email
See more Email Object Examples
Open forward-as-attachment.eml from the forwarding example. Read the cover note’s subject, then open each attached message and inspect its own headers and attachment count. This works even when the outer message has no ordinary files.
Chilkat Delphi ActiveX Downloads
var
success: Integer;
wrapper: TChilkatEmail;
nested: TChilkatEmail;
i: Integer;
begin
success := 0;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
wrapper := TChilkatEmail.Create(Self);
success := wrapper.LoadEml('forward-as-attachment.eml');
if (success <> 1) then
begin
Memo1.Lines.Add(wrapper.LastErrorText);
Exit;
end;
Memo1.Lines.Add('Cover note: ' + wrapper.Subject);
if (wrapper.NumAttachedMessages = 0) then
begin
Memo1.Lines.Add('No attached messages.');
Exit;
end;
nested := TChilkatEmail.Create(Self);
i := 0;
while (i < wrapper.NumAttachedMessages) do
begin
success := wrapper.GetAttachedEmail(i,nested.ControlInterface);
if (success <> 1) then
begin
Memo1.Lines.Add(wrapper.LastErrorText);
Exit;
end;
Memo1.Lines.Add('Original author: ' + nested.From);
Memo1.Lines.Add('Original subject: ' + nested.Subject);
Memo1.Lines.Add('Files on the original: ' + IntToStr(nested.NumAttachments));
i := i + 1;
end;