Mailx with attachment and html content

Hi, Please see my code below i'm trying get an email send with attachment and html content in the body.

Using the code below will put the encoding for attachment in the body as well

SUBJECT="$(echo  "XPI Monitoring "${tcnt}" transactions waiting \nContent-Type: text/html")"
            cat $RT_DIR/${RPT_DNAME[2]}/${XPILOG} > $TEMP_FILE
            uuencode $RT_DIR/${RPT_DNAME[2]}/${XPILOG} "xpimon.csv" >> $TEMP_FILE
            mailx -s "$SUBJECT" "$mailist" < $TEMP_FILE

Please shower some light if possible of what i'm doing wrong
Thanks

Save and examine the contents of temp_file. There are required blank lines close to the "content_type" line.
If need be, post the contents of temp_file, obscuring anything identifiable.

$TEMP_FILE is as follows.

m158xpimdir,m158xpisdte,m158xpistme, m158xpiprost,m158xpiprbm, m158xpiprst, m1ll, m1mcu, m1ldnm,m1kcoo, m1doco, m1dcto, m1lnid,m158xpiproc,m1user
O,117258,135109,S,TRIGGXPI,S,TS_NL,124030,0,,0,,0,PPLCALL_1,TSTXPI00
I,117258,83411,S,IS02,S,JTS_US,804030,0,,775900,,0,OMACONF_1,XPI
O,117258,135346,S,TRIGGXPI,S,TS_NL,124030,0,,0,,0,PPLCALL_1,TSTXPI00

This $TEMP_FILE will be converted with html tags later

What am really trying to do is send a mail with an attachment while the mail body is html as well.

any sample would be appreciate.

request

m@from.com~a@to.com~SUBJECT~42833379.memo~uel14647.pdf uel14827.pdf      

Send process

#!/bin/ksh                                                                
 IFS="~"                                                           
 cat requests/$request | read  user email subject memo attachments 
 IFS=" "                                                           
 delvmime $attachments <../requests/$request \                     
 |/usr/lib/sendmail -f$user $email       

Build content

#!/bin/ksh                                                                      
                                                                                
#Convert pdf file to mime encoded                                               
pdf(){                                                                          
echo Start pdf >>/tmp/delv.log                                                  
echo --PART-BOUNDARY.abcdefghijklmnopqrstuvwxyz                                 
echo X-Zm-Content-Name: `/bin/basename $filename.pdf`                           
echo "Content-Type: application/pdf; name=\"`/bin/basename $filename.pdf`\""    
echo "Content-Transfer-Encoding: base64"                                        
echo "Content-Dispostion: attachment;"                                          
echo "       filename=`/bin/basename $filename.pdf` \n"                         
b64encod <$filename.pdf                                                         
}                                                                               
#Convert eml file to mime encoded                                               
eml(){                                                                          
echo Start eml >>/tmp/delv.log                                                  
echo --PART-BOUNDARY.abcdefghijklmnopqrstuvwxyz                                 
echo X-Zm-Content-Name: `/bin/basename $filename.eml`                           
echo "Content-Type: application/eml; name=\"`/bin/basename $filename.eml`\""    
echo "Content-Transfer-Encoding: base64"                                        
echo "Content-Dispostion: attachment;"                                          
echo "       filename=`/bin/basename $filename.eml` \n"                         
b64encod <$HWD/$filename.eml                                                    
}                                                                               
#convert French language letters                                       
frn(){                                                                 
cd /u2/email/eps                                                       
echo '1d\nw\nq' |ed $HWD/$tiff                                         
cat /u2/email/escape /u2/email/letterhead $HWD/$tiff |\                
enscript -B -e -f Courier@10/11.6 -h -X ibmpc -p $HWD/$filename.ps     
ps                                                                     
}                                                                      
#convert French language letters                                       
tsa(){                                                                 
cd /u2/email/eps                                                       
echo '1d\nw\nq' |ed $HWD/$tiff >/dev/null 2>&1                         
cat /u2/email/escape  $HWD/$tiff |\                                    
enscript -B -e -f Courier@10/11.6 -h -X ibmpc -p $HWD/$filename.ps     
ps                                                                     
}                                                                      
#convert PS file to PDF   
#convert PS file to PDF                                          
ps(){                                                            
cd /u2/email/eps                                                 
ps2pdf $HWD/$filename.ps $HWD/$filename.pdf >>/tmp/ps2pdf.log    
cd $HWD                                                          
echo finished ps portion >>/tmp/delv.log                         
pdf                                                              
}                                                                
################Begin process################                    
IFS="~"                                                          
read UID TO SUBJECT MEMO discard                                 
IFS=" "                                                          
#UID=$1; export UID                                              
#TO=$2; export TO                                                
#SUBJECT=$3                                                      
#MEMO=$4                                                         
if [ ! -r $MEMO ]                                                
then                                                             
        MEMO=/u2/email/default.memo                              
fi                                                               
HWD=`pwd`; export HWD                                            
ed $MEMO </u2/email/ff.inp >/dev/null                            
HDRS=/u1/ltrs/header.txt; export HDRS                             TRLR=/u1/ltrs/trailer.txt; export TRLR                           
files="$*"                                                       
echo To: $TO                                                     
echo From: $UID                                                  
echo Reply-to: $UID                                              
echo Subject: $SUBJECT                                           
echo Remarks: $req                                               
echo Mime-Version: 1.0                                           
echo "Content-Type: multipart/mixed;"                            
echo "  boundary=\"PART-BOUNDARY.abcdefghijklmnopqrstuvwxyz\"\n" 
echo --PART-BOUNDARY.abcdefghijklmnopqrstuvwxyz                  
echo "Content-Type: text/plain; charset=us-ascii\n"              
cat $MEMO                                                        
echo                                                             
cat $TRLR                                                        
echo "\n"                                                        
echo `date` $req $files, all attachments >>/tmp/delv.log         
for tiff in $files                                               
do                                                               
EXT=`echo $tiff|cut -d"." -f2`       
 filename=`echo $tiff|cut -d"." -f1`           
#convert attachment based on extension
$EXT                                              
done                                              
echo --PART-BOUNDARY.abcdefghijklmnopqrstuvwxyz-- 

You will have to add a routine to convert a csv file and create a html section.