Email body not formatted with html and sendmail

Hi All,

I am trying to send the contents of a file as email body. I am using html email and sendmail option of unix. I am using the below piece of code for the same :

#!/usr/bin/ksh
export MAILTO="email@domain.com"
export SUBJECT="Report"
export BODY="file_directory_path/test_file.txt"
export ATTACH="file_directory_path/test_file.txt"
(
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 cat $BODY | column -t -s ","
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'$(basename $ATTACH)'"'
 echo "Content-Transfer-Encoding: base64"
 echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
 uuencode --base64 $ATTACH $(basename $ATTACH)
 echo '---q1w2e3r4t5--'
) | /usr/sbin/sendmail $MAILTO

But the output i am getting is :

"ABCD ASDFG" "N" "QWER" "" "90361" "AZ QWERTYU QWERTYUI" "E" "QWER" "20131021" "9" "AZ QWERTYU QWERTYUI" "E" "ASDF" "20131024" "9"

The output i require is :

"ABCD ASDFG"                  "N"  "QWER"  ""               "90361" 
"AZ QWERTYU QWERTYUI"  "E"  "QWER"  "20131021"  "9" 
"AZ QWERTYU QWERTYUI"  "E"  "ASDF"   "20131024"  "9"

The file_test.txt looks like:

"ABCD ASDFG","N","QWER","","90361"
"AZ QWERTYU QWERTYUI","E","QWER","20131021","9"
"AZ QWERTYU QWERTYUI","E","ASDF","20131024","9"

Please help me in formatting the email body !

The file "test_file.txt" is not html formatted so you need to append each line with a "<br>" on creation or editting it when it is streamed to sendmail - something like:

column -t -s "," ${BODY} | sed 's/$/<br\>/'

---------- Post updated at 09:41 AM ---------- Previous update was at 09:11 AM ----------

forgot you'll need to start the message body with paragraph tags so this is what you wind up with:

(
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo "<p>"
 column -t -s "," ${BODY} | sed 's/$/<br\>/'
 echo "</p>"
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'$(basename $ATTACH)'"'
 echo "Content-Transfer-Encoding: base64"
 echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
 uuencode --base64 $ATTACH $(basename $ATTACH)
 echo '---q1w2e3r4t5--'
) | /usr/sbin/sendmail $MAILTO