Re: Sending a HTML email with INDY 10.2.3 for Delphi 2005 (where the bug)

Giganews Newsgroups
Subject: Re: Sending a HTML email with INDY 10.2.3 for Delphi 2005 (where the bug)
Posted by:  Peter Ypenburg (pet…
Date: Thu, 4 Oct 2007

"Peter Ypenburg" <pet…> wrote in message
> Hi There,
> I had an app that was sending HTML emails with embedded images and was
> using Indy 10.0.52 in Delphi 2005 and it all worked fine.
> I then upgrade to Indy 10.2.3 and now it seems like it is broken, the
> picture that is was an embedded image now becomes an attachment and the
> HTML does not show.
> My dilemma is that I am not sure if it is a bug in Indy or a bug in my
> code because I made changes to my code based on some of the client
> requests and now I can not get it to work.
> I had a link to a sample program sending HTML emails with Indy but I lost
> that link. Here is a simplified version of my code can some tell me if
> there is a bug in my code?
> My HTML looks like this:
> <html> <head> <title>Happy Birthday</title> </head>
> <body > <table>
> <tr> <th> <H2>Dear EMPLOYEENAME</H2> </th> </tr>
> <tr> <td> <img src="cid:image1"> </td> </tr>
> </table> </body> </html>
> My code looks like this:
>      HTML := TStringList.Create;
> HTML.LoadFromFile(ExtractFilePath(Application.ExeName)+'HappyBirthday.htm');
>      IdMessage := TIdMessage.Create(Self);
>      IdMessage.Subject := 'Happy birthday';
>      IdMessage.Recipients.EMailAddresses := 'y…';
>      IdMessage.FromList.EMailAddresses := '…';
>      IdMessage.Body.Clear;
>      IdMessage.MessageParts.Clear;
>      with TIdText.Create(IdMessage.MessageParts, nil) do
>      begin
>        Body.Text := StringReplace(HTML.Text, 'EMPLOYEENAME', 'Someone',
> [rfReplaceAll]);
>        ContentType := 'text/html';
>      end;
>      with TIdAttachment.Create(IdMessage.MessageParts) do begin
>        ContentType := 'image/jpeg';
>        ContentLocation := ExtractFilePath(Application.ExeName);
>        FileName := 'HappyBday.jpg';
>        ContentID := 'image1';
>      end;
>      IdMessage.ContentType := 'multipart/relative; type="text/html"';
>      IdSMTP.Send(IdMessage);
> Any help is appreciated as my client needs me to give him working version.
> Thank you.
> --
> Peter
> Never ever give up,
> Hold out your cup,
> You never know when,
> You will get your zen.

I found the link I referred to above but
using that as sample code also have the same results, the JPG file just
comes through as an attachment on the email with the HTML not showing and
the JPG not in embedded HTML.

Any ideas?


In response to

Sending a HTML email with INDY 10.2.3 for Delphi 2005 (where the bug) posted by Peter Ypenburg on Thu, 4 Oct 2007