![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to attach a file in Linux mail command | rohit22hamirpur | Shell Programming and Scripting | 1 | 12-05-2008 01:58 AM |
| How to attach a file & send mail thru script | Mar1006 | Shell Programming and Scripting | 9 | 10-12-2006 08:54 AM |
| Need to attach a txt file while sending mail | charan81 | Shell Programming and Scripting | 9 | 01-12-2006 01:44 AM |
| How to attach an excel file/ dat file thru unix mails | diwakar82 | Shell Programming and Scripting | 1 | 01-06-2006 11:23 AM |
| How to attach a file in mail? | firebirdonfire | UNIX for Dummies Questions & Answers | 1 | 03-29-2001 07:38 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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...
Code:
echo "hello,world" > file.csv uuencode file.csv file.csv | mailx -m -s "Excel file" your_email_addr |
|
||||
|
give this a try
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 - for month end $monthd $year - file should be att. - from UNIX "william.g.loughran@yourcompany.com" |
|
||||
|
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. |
![]() |
| Bookmarks |
| Tags |
| mime attachment |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|