How to attach an excel file in a multipart (mime) mail

Hello.

I need to send mails from hp-ux with 2 attachments: a text file and an excel file. So I'm composing a mime file which I will pipe to sendmail utility.

This works fine if the only attachment is the text file (i use cat command to attach text content). But I have problems with the format when I try to open the sent excel file. I have tried cat, uuencode, od... I've changed the 'encoding' (binary, base64, etc).

My code is like this (progress environment, put is like echo):

put "------------thisss isss aaa boundddaaarrryyy" skip.
put 'Content-Type: text/plain; charset=us-ascii; name="' (p_filename + '"') format "x(30)" skip.
put "Content-Transfer-Encoding: 7bit" skip.
put 'Content-Disposition: attachment; filename="' (p_filename + '"') format "x(30)" skip(1).
unix silent cat value(p_filepath).

put "------------thisss isss aaa boundddaaarrryyy" skip.
put 'Content-Type: application/octet-stream; name="' (p_filename2 + '"') format "x(30)" skip.
put "Content-Transfer-Encoding: base64" skip.
put 'Content-Disposition: attachment; filename="' (p_filename2 + '"') format "x(30)" skip(1).
unix silent uuencode value(p_filepath2) value(p_filepath2).

The output file (mime.txt) is piped to sendmail like this:
par = '-F"' + p_fullname + '" -bm -t -rxxxxx@xxxxx.com'.
unix silent cat ./tmp_cnt_mime.txt | /usr/sbin/sendmail value(par)

Any idea??
Does anyone know another solution??

Only way I know is to create a csv file and save it with a .csv extension and then attach it to mailx with the uuencode utility...

echo "hello,world" > file.csv
uuencode file.csv file.csv | mailx -m -s "Excel file" your_email_addr

if you can follow - automatic date - for last month
probably a better way - take a look

ext=_FINAL_s
space=_
year=$(date +%Y)
month=$(date +%m)
monthh=$(date +%h)
day=$(date +%d)

month=$(($month-1))
if [ $month -lt 1 ]
then
year=$(($year-1))
month=12
fi

if [ $month -eq 1 ]
then monthd=JAN
elif [ $month -eq 2 ]
then monthd=FEB
elif [ $month -eq 3 ]
then monthd=MAR
elif [ $month -eq 4 ]
then monthd=APR
elif [ $month -eq 5 ]
then monthd=MAY
elif [ $month -eq 6 ]
then monthd=JUN
elif [ $month -eq 7 ]
then monthd=JUL
elif [ $month -eq 8 ]
then monthd=AUG
elif [ $month -eq 9 ]
then monthd=SEP
elif [ $month -eq 10 ]
then monthd=OCT
elif [ $month -eq 11 ]
then monthd=NOV
elif [ $month -eq 12 ]
then monthd=DEC
fi

echo $day
echo $month
echo $monthd

uuencode CP_template_$monthd$space$year$ext.xls < /cqdata10/data_0/CP_template_$
monthd$space$year$ext.html | mailx -m -s "SPECIAL Auto. e-mail - C/P - dq Stats

Install Perl and the module MIME::Lite. Then you can just build your message and add the attachment with the correct mime information to be sent out.
It would really only take a couple of lines and give you the ability to write some code with flexibility to use in other situations.