Sample code for 30+ languages & platforms
Delphi DLL

Save HTML Email Embedded Images

Saves HTML embedded items to files in a subdirectory. Images, style sheets, and anything else embedded within HTML, are not considered to be attachments. Instead, these items are "related item". The Chilkat email object provides a set of methods/properties for accessing the related items within an email.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
email: HCkEmail;
i: Integer;
numRelated: Integer;

begin
success := False;

email := CkEmail_Create();

//  Load an email object containing HTML with embedded images.

success := CkEmail_LoadEml(email,'myEmails/HtmlEmail.eml');
if (success <> True) then
  begin
    Memo1.Lines.Add(CkEmail__lastErrorText(email));
    Exit;
  end;

//  Iterate over the related items.  
//  Print the file name and save each to a file.
i := 0;
numRelated := CkEmail_getNumRelatedItems(email);
while i < numRelated do
  begin

    Memo1.Lines.Add(CkEmail__getRelatedFilename(email,i));

    success := CkEmail_SaveRelatedItem(email,i,'myRelatedItemsDir');
    if (success <> True) then
      begin
        Memo1.Lines.Add(CkEmail__lastErrorText(email));
        Exit;
      end;
    i := i + 1;
  end;

CkEmail_Dispose(email);