Sending a mail with different attachment in AIX

How to Send a mail with multiple attachment also differenet extension using uuencode in AIX.

Can you please help me.

---------------------------------------------------------

I have below code. But attachment not been attached.

(cat /aceapp/QATD011R4/ace.ofac/testofac/results/;uuencode /aceapp/QATD011R4/ace.ofac/testofac/results/*.* *.*) | mail -s "Summary Report" smawle@acesw.com
for i in /aceapp/QATD011R4/ace.ofac/testofac/results/
 do
 uuencode ${i} ${i%.*}.txt
 done > attach.out
  
 mail -s "Summary Report" smawle@acesw.com < attach.out

The given code is sending attachment but in binary format, additionally can we send the contents mentioned in the attached file in mail body too.

If the files are in binary format or if they are encrypted, you can see them in binary...
for example, if you have the extension of a pdf or doc file to txt and try to open it using notepad, you cannot read the text

Thanks Srinishoo.

I am trying below code for attached multiple % summary % csv files in email. However, not able to attached it. Also, we only required Summary files in particular folder.

eg. In result folder 100 csv file we need to fetched only summary file. ( SDN_WCFINCEN_summary_20151013_111216.csv )
So, that in code we had mentioned that %summary%.csv

Below are code we are using.

(cat /aceapp/QATD011R4/ace.ofac/testofac/results/%summary*.*;uuencode /aceapp/QATD011R4/ace.ofac/testofac/results/summary*.* %summary*.*) | mail -s "Summary Report" smawle@acesw.com

Your help is highly appreciated.

Thanks.

Regards,
Swap nil

There are no percent sign characters in the pathname SDN_WCFINCEN_summary_20151013_111216.csv and percent sign characters in a pathname pattern matching expression match literal percent sign characters. It would seem that you want to use something more like:

pathname=$(printf '%s' /aceapp/QATD011R4/ace.ofac/testofac/results/*summary*.csv)
(cat "$pathname";uuencode "$pathname" "${pathname##*/}") | mail -s "Summary Report" smawle@acesw.com

which will give you plain text and unencoded text in the body of the mail. But, it will only work if there is one and only one file in that directory that contains the string summary and ends with the string .csv .

Thanks Don for your reply.

After ran the code, we have received the plain mail. No attachment in that mail. Also, no text in mail body.

In Result folder we have around 25 csv files out of 8 files belong to Summary CSV files and all these 8 files we need to attached in the mail.

Please help me to solve the problem.

Thanks.

Regards,
Swapnil

Try using sendmail:-

#!/bin/ksh

MAILFR="fromaddr@domain.com"
MAILTO="toaddr@domain.com"
SUBJECT="Summary Report"
MAILPART=$(uuidgen)
MAILPART_BODY=$(uuidgen)

(
        echo "From: $MAILFR"
        echo "To: $MAILTO"
        echo "Subject: $SUBJECT"
        echo "MIME-Version: 1.0"
        echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
        echo "--$MAILPART"
        echo "Content-Type: multipart/alternative; boundary=\"$MAILPART_BODY\""
        echo ""
        echo "--$MAILPART_BODY"
        echo "Content-Type: text/plain"
        echo "Content-Disposition: inline"
        echo ""
        echo "This is email body"
        echo "--$MAILPART_BODY--"
        for file in /aceapp/QATD011R4/ace.ofac/testofac/results/*summary*.csv
        do
                echo ""
                echo "--$MAILPART"
                echo 'Content-Type: test/csv; name="'$(basename $file)'"'
                echo "Content-Transfer-Encoding: base64"
                echo 'Content-Disposition: attachment; filename="'$(basename $file)'"'
                echo ""
                base64 $file
                echo "--$MAILPART"
        done
) | /usr/sbin/sendmail -t

Thanks Yoda.

I have execute above code but we wont have any packages like uuidgen or MIME so I got the error message

uuidgen not found
base 64 not found

Please let me know if you have any code without packages.

Thanks.

Regards,
Swapnil

uuencode is not recommended and now been largely replaced by MIME

Anyway check these threads in FAQ section.