How to send email as HTML format with attachment ?

hi..

Could somebody help me how to sent an attachment using sendmail command and the content is HTML format ?.

Below is my code to sent the email as HTML but i do not know how to sent the attachment, please help me

To: "BAHARIN HASAN"<baharin.hasan@gmail.com>
from: "DATAONE SDN BHD"<admin@dataone.asia>
Subject: test
Content-Type: text/html
charset="us-ascii"

<html>
<head>
<title>Your Page Title</title>
</head>

<body>
<center>
<table border=0>
  <tr>
    <th><img border=0 src=/images/pulpit.jpg alt=Pulpit rock width=67 height=92 /></th>
    <th><p>�</p><h2>Bill Statement</h2></th>
  </tr>

  <tr>
  <td><h4>Dear <ASMAH_AHMAD>,</h4>
  <p>Thank you for your valued subscription to our<br/>
     services.Your TM bill statement is now attached as <br/>
     an Adobe PDF file in this email.</p>
  <p>Thank You</p></td>
  <td><p>Account No.</p><p><12345></p>Statement Date.<p><12/12/2010></p></td>
  </tr>
</table>
<center><img src=example.jpg alt=example/></center>
</center>
</body>
</html>

Thank you,
baharin

Your "code" is an html-encoded file. There are two ways the easiest one

# assume your html-encoded file is named: t.htm
uuencode t.htm t.htm | mailx -s 'subject goes here'  somebody@yourcompany.com

The other way requires base64 encoding using perl base64. Since most machines do not have that installed already, option #1 is easier.

Thank for your reply..

How about the attachment ?... is it your code will be sent the attachment ?

There's no easy way to fulfill your requirements from the command line. Sending HTML emails: easy. Sending HTML emails with images and an attached PDF: not so easy. The problem is that you'll either have to provide a full URL for the images, or attach them too.

Instead of sending from the command line, I'd suggest taking a look at MIME::Lite. It even includes an example of how to send an HTML mail with images.

Also suggest you look at the mutt mailer. It has a command line option (-a) to attach one or more files using MIME.