Link to home
Start Free TrialLog in
Avatar of Zuhair070699
Zuhair070699

asked on

Send Html mail

Hi,

Is there is a way to send html page using NMSMTP component without using external component?

Thanks,
Avatar of rondi
rondi

All you need to do to send HTML mail is to add a custom header to the message:
  Content-type: text/html

The body of the message would contain HTML code.

The one thing you will have problems with, is including
images in the message. If you take a close look at the source of MS Outlook Express HTML messages, you'll notice that the images UUencoded and included in the message - the links to the images look like: mk:image1.gif
or something.
Hello Zuhair,

Just set the "Content-Type:text/html" header.

Best Regards

Cesario
Avatar of Zuhair070699

ASKER

Hi,

Thank you all .. I use NMSMTP  componant, so where shall I put the header: Content-type: text/html  ??
Hi Zuhair,


  with NMSMTP1 do
    begin
      FinalHeader.Add('Test');
      PostMessage.ToAddress.Add('prioux@videotron.ca');
      PostMessage.FromAddress := 'prioux@videotron.ca';
      PostMessage.Subject     := 'Sending html format';
      PostMessage.Date        := DateToStr(Date);
      PostMessage.Body.LoadFromFile('C:\test2.html');
      SubType := mtHtml;
      Connect;
      SendMail;
      Disconnect;
   end;

Best Regards

Cesario
Thanks,

But I still got plain text messsage !

Any idea ?
Make sure the body of the message has HTML tags:

<HTML>
 <BODY>
  <P>
    Hi, this is an HTML message.
 </BODY>
</HTML>
Still the same problem.. do you test your code ?
Sorry, the HTML code should've included some markup:

<HTML>
<BODY>
 <P>
   Hi, <u>this</u> is an <b>HTML<b> <i>message<i>.
 <hr>
 <P align="center">
   <font color="silver">End of Message</font>
</BODY>
</HTML>

I use the ICS component suite - all's I gotta do to send HTML mail is add a custom header
 Content-type: text/html
then set the body string to my HTML source(above).

To 'debug', you should try to view the source of the message in your mail client to see if it contains the HTML tags. If you're using Outlook Express this should be under File->Properties, if you're using Outlook (Office), then save the message and open the
.msg file in notepad or something.

rondi.
I am really appretiate your help but could you please take a look to my code:


 NMSMTP1.Connect;
 NMSMTP1.FinalHeader.Add('Content-Type:text/html');
 NMSMTP1.EncodeType := uuMime;
 NMSMTP1.PostMessage.FromAddress := 'System';
 NMSMTP1.PostMessage.FromName := 'System Administrator';
 NMSMTP1.PostMessage.ToAddress.Clear;
 NMSMTP1.PostMessage.ToAddress.Add('my@email.me');
 NMSMTP1.PostMessage.Body.LoadFromFile('c:\test2.html');
 NMSMTP1.PostMessage.Subject := 'title';

 If NMSMTP1.Connected then
       NMSMTP1.SendMail;

========================================================
test2.html file is what you posted:

<HTML>
<BODY>
<P>
  Hi, <u>this</u> is an <b>HTML<b> <i>message<i>.
<hr>
<P align="center">
  <font color="silver">End of Message</font>
</BODY>
</HTML>


========================================

after i run the script I got an email with plain text NOT html.

Any idea?

Thanks


ASKER CERTIFIED SOLUTION
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

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
With this line:
 NMSMTP1.SubType := mtHTML;  

These are not needed:
 NMSMTP1.FinalHeader.Add('Content-Type:text/html');
 NMSMTP1.EncodeType := uuMime;
Zuhair:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

split points between Cesario and EddieShipman

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer