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)
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.