Link to home
Start Free TrialLog in
Avatar of bussoftware
bussoftware

asked on

sending email containing rtf or html

Is it possible to send an email which contains rtf or html text? So far I know it's not possible with the fastnet components delivered with D5.

Thanks for your help.
Avatar of rwilson032697
rwilson032697

listening
The NMSMTP component that ships with Delphi is simply not up to the job as it's 'body' is merely a stringlist. If you want to go down this route (which I don't think you do but I'm not going to spoil my brief second of greatness) then you could send your RTF/HTML as an attachment. I bet this isn't what you want to do though is it?

The Neil
Avatar of bussoftware

ASKER

Neil, you are right. The thought with the attachement I had before I asked this question. But is there nocomponent available, which is able to send rtf-bodies?

Olaf
Olaf,

There isn't a component that I know of but I don't claim to be an expert on 3rd party components so maybe a look at Torry's web page might help? (Sorry, I don't know the address off the top of my head but a quick search on www.AltaVista.com should sort you out).

The Neil
hi,
there is one way to do such thing with fastnet comps. i'm not sure if it works with D5, but it works with my D4.
if you look at message header (which you have send using TNMSMTP) i.e. in netscape messenger, you will see field 'Content-Type: text/plain; charset=us-ascii'. that's the point. you need to change this to text/html.
TNMSMTP has property SubType which i think doesn't work or is for something different, because nothing changes in message header when you change this property. however there is property FinalHeader, which is filled just before sending the message. it is filled when you call SendMail, but you can change it in OnSendStart event.

procedure TForm1.NMSMTP1.SendStart(Sender: TObject);
var
  i:integer;
begin
  for i:=0 to NMSMTP1.FinalHeader.Count-1 do
    if pos('Content-Type',NMSMTP1.FinalHeader[i])>0 then
      NMSMTP1.FinalHeader[i]:='Content-Type: text/html; charset=us-ascii';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  NMSMTP1.connect;
  NMSMTP1.sendmail;
  NMSMTP1.disconnect;
end;

just fill all other fields with info you need and place in message body html code.

for rtf mail i think there should be 'Content-Type: text/rtf; charset=us-ascii'

A.
Hi,
I use for that the Mail2000 components.
You can find it at Torry pages: http://www.torry.ru
(Unfortunately I don't remember the exact address where I find them)
Using them you can send either HTML or RTF bodies.

Regards,
Kot
listenning
listenning
To A.

I think this is the right way. But I still have one problem. I don't use the TNMSMTP Component on a form, but create it myself with SMTP1 := TNMSMTP.Create(Application). Do you know how to write the eventhandler "OnSendStart" in this case?

Thanks for your help.

Olaf
ASKER CERTIFIED SOLUTION
Avatar of 333
333

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot.
Hello A.

html is ok, rtf doesn't work. I used MS Outlook and Outlook Express. However, this shouldn't be the point. I think that the email programs aren't able to show rtf-format.

greetings, Olaf
maybe you're right.
i have never received a rtf email, so i can't check it.
i'm using nescape which i think can't display rtf.
if you have also client, which can send/show rtf email, i suggest you to look at message header. maybe content-type should be something other.