Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

INDY : Sending Email in HTML format via INDY component, how?

263 views
Skip to first unread message

Ebadat A.R.

unread,
Nov 27, 2001, 5:38:01 AM11/27/01
to
Dear Colleague ,
I'm using Indy component for email programing. I'm using TIdSMTP and TIdPOP3
and TIdMessage. I want to send email in HTML format. I wont to send it as
attachment.
format for sending email.
Thank you ,
Ebadat A.R.


Hadi Hariri - Team Indy

unread,
Nov 27, 2001, 7:50:34 AM11/27/01
to
The demo extensively shows you how to send plain, html and multi-part
emails.


Tim Sullivan

unread,
Nov 27, 2001, 12:21:37 PM11/27/01
to
> The demo extensively shows you how to send plain, html and multi-part
> emails.

Extensive, but not functional. The supplied demo will NOT send HTML and an
attachment. It just doesn't work. I've given up on using Indy for HTML email
for now because of this, and was waiting for a fix. There are tons of
unanswered, unacknowledged postings in this newsgroup asking about this.

--
Tim Sullivan
Unlimited Intelligence Limited
Dimethylaminoethanol for your software
http://www.uil.net


Tim Sullivan

unread,
Nov 27, 2001, 12:23:19 PM11/27/01
to
I forgot to add that I understand that this is a volunteer effort, and I'm
not trying to blame or accuse. Rereading the message, it sounds more harsh
than it is intended. :-)

Kudzu

unread,
Nov 27, 2001, 1:45:16 PM11/27/01
to
"Tim Sullivan" <t...@NO.SPAM.FOR.ME.uil.net> wrote in
news:3c03cc09$1_1@dnews:
> Extensive, but not functional. The supplied demo will NOT send HTML and
> an attachment. It just doesn't work. I've given up on using Indy for HTML
> email for now because of this, and was waiting for a fix. There are tons
> of unanswered, unacknowledged postings in this newsgroup asking about
> this.

Indy 9 is still beta. As for Indy 8, a lot fo them go uanswered because its been answered a billion times and a
quick google search will find the answer.

--
Chad Z. Hower (Kudzu) - http://www.pbe.com/Kudzu/
Current Location: St. Petersburg, Russia
"Programming is an art form that fights back"

IntraWeb - True RAD Development for the web
http://www.pbe.com/IntraWeb

Thilo Stäbler

unread,
Nov 27, 2001, 3:35:11 PM11/27/01
to
Hi!
just have a look at the demo and replace ContentType:= text/plain by
text/html

here a fast hack howto scan attachments (only for text/plain text/html) but
binary attachments are handled very similar...

if (SMTPThread[ThreadID].MailDataIN.MessageParts.Items[intIndex] is
TIdText) then
begin
if
pos('html',lowercase(SMTPThread[ThreadID].MailDataIN.MessageParts.Items[intI
ndex].ContentType)) > 0 then
fname := MsgPath+'\0'+IntToStr(intIndex)+'.html'
else fname := MsgPath+'\0'+IntToStr(intIndex)+'.plain';
try

TIdText(SMTPThread[ThreadID].MailDataIN.MessageParts.Items[intIndex]).Body.S
aveToFile(FName);
except
Log('Error saving plain/html');
end;
end;

scan your attachmenst / html / plain for whatever (virus/ ....)
and rebuild your message ( I think your problem is here....)

....
with TIdText.Create(SMTPThread[ThreadID].MailDataIN.MessageParts,
LoadList) do
begin
if MIME = plain then ContentType := 'text/plain'
else ContentType := 'text/html';
end;
except
.....

thats it!!! not really difficult....
Thilo

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs and the Universe producing bigger and
better idiots - so var, the Univers is winnning. -- Rich Cook


"Ebadat A.R." <ARe...@Mabnasoft.com> schrieb im Newsbeitrag
news:3c036d11_1@dnews...

Don Siders - Team Indy

unread,
Nov 28, 2001, 12:47:07 AM11/28/01
to

"Tim Sullivan" <t...@NO.SPAM.FOR.ME.uil.net> wrote in message
news:3c03cc09$1_1@dnews...

> > The demo extensively shows you how to send plain, html and multi-part
> > emails.

> Extensive, but not functional. The supplied demo will NOT send HTML and an
> attachment. It just doesn't work.

If you're trying to put 'text/html' in the TIdMessage.ContentType, html in
the TIdMessage.Body,
and attachment of some sort, then it it will not work. That is a
multipart message. You need to create TIdText or TIdAttachment instances
for each message part, and set the TIdMessage.ContentType.
'multipart/alternative' if all message parts are TIdText, and
'multipart/related' if a TIdAttachment is involved that has a 'content-id'
header.

> I've given up on using Indy for HTML email
> for now because of this, and was waiting for a fix. There are tons of
> unanswered, unacknowledged postings in this newsgroup asking about this.

I've seen messages on this topic from time to time. Try
http://groups.google.com. There is also an
IndyMailDemo.zip file posted in the attachments group.

hth...

Hadi Hariri - Team Indy

unread,
Nov 28, 2001, 3:07:39 AM11/28/01
to
The demo in version 9 of indy doesn't work? Are you sure? I will check into
it but last when I worked on it it was working fine.


Ralph Friedman

unread,
Nov 28, 2001, 10:34:27 AM11/28/01
to
Don,

in article <3c047a2f$1_1@dnews>, you wrote:

> There is also an
> IndyMailDemo.zip file posted in the attachments group.
>

but it is missing something called "HTMLLite"

--
Regards
Ralph (TeamB)
==
Use Borland servers; TeamB doesn't see posts via ISPs
http://www.borland.com/newsgroups/genl_faqs.html
==
We do not quit playing because we grow old,
we grow old because we quit playing.

Tim Sullivan

unread,
Nov 28, 2001, 10:58:09 AM11/28/01
to
> The demo in version 9 of indy doesn't work? Are you sure? I will check
into
> it but last when I worked on it it was working fine.

Specifically it didn't work with html email and an attachment. If you can
give me step-by-step instructions to get it to work, I think I might propose
to you. :-)

This is one of the things that Indy should handle automatically, though,
isn't it? If a user creates an HTML message and a file attachment, shouldn't
the component set the whole message to multipart/alternative or
multipart/related based on property settings?

Keep me informed. I'm eager to know what the solution is!

Hadi Hariri - Team Indy

unread,
Nov 28, 2001, 2:29:04 PM11/28/01
to

> This is one of the things that Indy should handle automatically,
> though, isn't it? If a user creates an HTML message and a file
> attachment, shouldn't the component set the whole message to
> multipart/alternative or multipart/related based on property settings?

No. You can sent attachments without it having to be multipart/alternative.
It would be multipart/mixed. Set the contetn-type to text/html and then add
attachments. If that doesn't work let me know since it should and somehow
it's broken.

Don Siders - Team Indy

unread,
Nov 28, 2001, 2:57:47 PM11/28/01
to

"Ralph Friedman (TeamB)" <rft...@utanet.at> wrote in message
news:VA.000010e...@utanet.at...

> but it is missing something called "HTMLLite"

Oops. That's some IDE droppings in the uses clause. Just remove it.

Ralph Friedman

unread,
Nov 28, 2001, 4:09:11 PM11/28/01
to
Don,

in article <3c05418e$1_2@dnews>, you wrote:

> Oops. That's some IDE droppings in the uses clause. Just remove it.
>

Evidently SaveToStream was added to TidMessage in Beta 2. Downloading as we
speak.

Tim Sullivan

unread,
Nov 28, 2001, 7:08:15 PM11/28/01
to
> No. You can sent attachments without it having to be
multipart/alternative.
> It would be multipart/mixed. Set the contetn-type to text/html and then
add
> attachments. If that doesn't work let me know since it should and somehow
> it's broken.

I've not tried it in a few weeks, but when I posted my question some time
ago, I had done just that. Give it a shot at your end and let me know if you
manage to get it working. For some reason, at my end, it gets changed back
to text/plain, even though I'd set it correctly.

Don Siders - Team Indy

unread,
Nov 29, 2001, 12:12:48 AM11/29/01
to

"Tim Sullivan" <t...@NO.SPAM.FOR.ME.uil.net> wrote in message
news:3c0509f4$1_2@dnews...

> Specifically it didn't work with html email and an attachment. If you can
> give me step-by-step instructions to get it to work, I think I might
propose
> to you. :-)


Tim:

Here's a code example that I just used to send an HTML email with a binary
attachment. It contains both a text/plain and a text/html message part. It
does not set the ContentType for the message, just the text message parts.
Indy is handling the content type for the entire message.

hth...

vMsg := TIdMessage.Create(Self);

vMsg.From.Text := EditFrom.Text;
vMsg.Recipients.EMailAddresses := EditTo.Text;
vMsg.Subject := 'This is a multipart/mixed message';

with TIdText.Create(vMsg.MessageParts) do
begin
ContentType := 'text/plain';

Body.Add('Hello World...');
Body.Add('');
Body.Add('Paragraph One.');
Body.Add('');
Body.Add('Paragraph Two.');
Body.Add('Paragraph Three.');
Body.Add('');
end;

with TIdText.Create(vMsg.MessageParts) do
begin
ContentType := 'text/html';

Body.Add('<html>');
Body.Add('<body>');
Body.Add('<h1>Hello World...</h1>');
Body.Add('<p style="color: Red">Paragraph One.</p>');
Body.Add('<p style="color: Green">Paragraph Two.</p>');
Body.Add('<p style="color: Blue">Paragraph Three.</p>');
Body.Add('</body>');
Body.Add('</html>');
end;

with TIdAttachment.Create(vMsg.MessageParts, 'testMail.res') do
ExtraHeaders.Add('content-id=CID:bogus');

with IdSMTP1 do
begin
Host := EditSMTPServer.Text;
try
Connect;
Send(vMsg);
finally
if Connected then Disconnect;
end;
end;

vMsg.Free;


Gregor Ibic

unread,
Nov 29, 2001, 2:38:33 PM11/29/01
to
Sending emails in HTML format with Indy works just OK.
Im sending a lot of emails this way. You only have to rewrite urls of
embedded images.

If interested I have a sample.

Regards,
Gregor


Tim Sullivan

unread,
Nov 29, 2001, 6:57:54 PM11/29/01
to
> Here's a code example that I just used to send an HTML email with a binary
> attachment. It contains both a text/plain and a text/html message part.
It
> does not set the ContentType for the message, just the text message parts.
> Indy is handling the content type for the entire message.

Thanks, Don. If this works, you'll have my unending thanks.

Hell, you have my unending thanks anyway! :-)

Fred

unread,
Nov 30, 2001, 3:38:55 PM11/30/01
to
Hi,

I would be interested in seeing this example if you could post it in the
attachments board.

TIA.

Fred

"Gregor Ibic" <grego...@intelicom.si> wrote in message
news:3c068d68_1@dnews...

Fred

unread,
Dec 1, 2001, 7:02:12 AM12/1/01
to
Hi,

I would be interested in seeing this example if you could post it in the
attachments board.

TIA.

Fred

"Gregor Ibic" <grego...@intelicom.si> wrote in message
news:3c068d68_1@dnews...

Neal Zhao

unread,
Dec 4, 2001, 2:19:54 AM12/4/01
to
"Ebadat A.R." <ARe...@Mabnasoft.com> wrote in news:3c036d11_1@dnews:

Hi,

I have add some code let it support inline img in the html email.

1.May be there have a bug in the TidMessageClient.SendBody
if AMsg.MessageParts.TextPartCount > 0(1) then begin

2.You must add content-id field to the TidAttachment
3.change the Img tag with follow :
Img Src="dddd.gif" to Img Src="cid:img1.ddd"
4.Add the attachments to the message and set the contentid with img1.ddd

Then you can sent it and read it from outlook.

:-)

Neal

0 new messages