Generate HTML e-mail with embedded images in Delphi

后端 未结 5 1946
感情败类
感情败类 2020-12-11 06:28

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 em

相关标签:
5条回答
  • 2020-12-11 07:05

    It all depends on how many different remote mail clients you have to be able to support. I believe that the well-known Delphi libraries which support SMTP/Mime will do a reasonable job, but they may leave you with support problems when one of your mail users finds that their recipient cannot see a properly formatted e-mail.

    I recommend visiting Jacob Palme's site which will give you an idea of some of the problems that you may encounter. It is a little out-of-date, perhaps, but in summary, however you build and send your complex MIME e-mail, you will encounter one or more mail clients which cannot handle the syntax properly. The site also has links to some useful examples of constructions which you can examine and test.

    I do not mean to imply that you have to roll your own logic as we did: a good packaged solution will probably be successful in the great majority of cases. We wrote our own Delphi code to handle this some years ago, so I will leave it for others to give you up-to-date information about what is on the shelf now.

    0 讨论(0)
  • 2020-12-11 07:06
    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;
    
    0 讨论(0)
  • 2020-12-11 07:15

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

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

    0 讨论(0)
  • 2020-12-11 07:17

    We tried this years ago with Indy and embedded cid: images like this: https://forums.codegear.com/thread.jspa?threadID=17473

    We never got it stable, each time there was another mail reader that barfed (if we got it working in Outlook, then Thunderbird didn't accept it, or Outlook Express, or, etc, etc).

    In the end we did it with .NET using AspNetEmail and it worked like a charm.

    --jeroen

    0 讨论(0)
  • 2020-12-11 07:18

    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

    0 讨论(0)
提交回复
热议问题