Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate HTML e-mail with embedded images in Delphi

Anyone know of a good example of generating HTML e-mail with embedded images and an alternate text part? I need to generate some tabular reports in HTML and would like to embed logos and other images.

I believe Indy can do this with some work, but I was hoping someone could point me to a good example as a starting point. I am open to using libraries other than Indy and commercial solutions provided source is available. Quality and time to implement is more important than cost. The solution also needs to support SMTP based delivery to a mail exchanger.

The other item on my wish list is to be able to leverage FastReports, TRichView or similar tool to generate the HTML message content. There are HTML output filters available for both, but I have not had the opportunity to do any testing. Any feedback on this subject would be appreciated.

Thanks in advance!

David

like image 336
David Taylor Avatar asked Oct 14 '09 22:10

David Taylor


3 Answers

Read the following articles on Indy's website, they explain the proper way to populate a TIdMesaage for HTML:

HTML Messages

New HTML Message Builder class

like image 176
Remy Lebeau Avatar answered Nov 19 '22 19:11

Remy Lebeau


These days I use Clever Component's email client, though not free.

The TurboPower Internet (OpenSource) controls worked great for me in the past.

like image 40
Hein du Plessis Avatar answered Nov 19 '22 18:11

Hein du Plessis


function data64(const filename:string): ansistring;
// uses Classes, IdGlobalProtocols, EncdDecd;
const
  crlf = #13#10;
begin
  result := '';
  with TIdMimeTable.Create do
  try
    result := 'data:'
      + GetFileMIMEType(filename) + ';';
  finally
    Free;
  end;
  with TMemoryStream.Create do
  try
    LoadFromFile(filename);
    result := result + 'base64,' + crlf
      + EncodeBase64(Memory,Size);
  finally
    Free;
  end;
end;
like image 1
Srba Avatar answered Nov 19 '22 18:11

Srba