[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

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.
0
bussoftware
Asked:
bussoftware
  • 4
  • 3
  • 2
  • +3
1 Solution
 
rwilson032697Commented:
listening
0
 
TheNeilCommented:
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
0
 
bussoftwareAuthor Commented:
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
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
TheNeilCommented:
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
0
 
333Commented:
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.
0
 
kotikCommented:
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
0
 
bryan7Commented:
listenning
0
 
bryan7Commented:
listenning
0
 
bussoftwareAuthor Commented:
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
0
 
333Commented:
it's simple:

after
SMTP1 := TNMSMTP.Create(Application);
write
SMTP1.OnSendStart:=MySendStart;
where MySendStart is method of any object you have. i.e if you have TForm, you can do so:

type
  TForm1 = class(TForm)
  ...
  procedure MySendStart(Sender: TObject);
  ...
  end;

if you create everything at runtime, you can make a descendant from TNMSMTP:

type
  TSMTP = class(TNMSMTP)
     constructor Create(AOwner:TComponent); override;
     procedure MySendStart(Sender: TObject);
  end;

constructor Create(AOwner:TComponent);
begin
  inherited Create(AOwner);
  OnSendStart:=MySendStart;
end;

procedure TSMTP.MySendStart(Sender: TObject);
begin
   {anything you need}
end;

A.
0
 
bussoftwareAuthor Commented:
Thanks a lot.
0
 
bussoftwareAuthor Commented:
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
0
 
333Commented:
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.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 4
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now