|Subject:||Re: Sending a HTML email with INDY 10.2.3 for Delphi 2005 (where the bug)|
|Posted by:||Peter Ypenburg (pet…@mms.za.net)|
|Date:||Thu, 4 Oct 2007|
"Peter Ypenburg" <pet…@mms.za.net> 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;
> IdMessage := TIdMessage.Create(Self);
> IdMessage.Subject := 'Happy birthday';
> IdMessage.Recipients.EMailAddresses := 'y…@birthday.some.place';
> IdMessage.FromList.EMailAddresses := '…@birthday.some.place';
> with TIdText.Create(IdMessage.MessageParts, nil) do
> Body.Text := StringReplace(HTML.Text, 'EMPLOYEENAME', 'Someone',
> ContentType := 'text/html';
> with TIdAttachment.Create(IdMessage.MessageParts) do begin
> ContentType := 'image/jpeg';
> ContentLocation := ExtractFilePath(Application.ExeName);
> FileName := 'HappyBday.jpg';
> ContentID := 'image1';
> IdMessage.ContentType := 'multipart/relative; type="text/html"';
> Any help is appreciated as my client needs me to give him working version.
> Thank you.
> 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
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.
Sending a HTML email with INDY 10.2.3 for Delphi 2005 (where the bug) posted by Peter Ypenburg on Thu, 4 Oct 2007