Not able to send attachment with the email

Hi All,
The below code is working fine for me.

 mailx -s hello abc@xyz.com <<EOT

Hello !!!

How are you?

Regards
Rahul
EOT

But i am not able to send csv file with the mail .Getting just themail but not the attachment.

uuencode /path/s1.csv | mailx -s hello abc@xyz.com <<EOT

Hello !!!

How are you?PFA for the file.

Regards
Rahul

EOT

Try :

cat >msg<<EOT
Hello !!!

How are you?PFA for the file.

Regards
Rahul
EOT


$ ( cat msg ; uuencode /path/s1.csv ) | mailx -s hello abc@xyz.com

How??
Please show the full syntax

---------- Post updated at 11:56 AM ---------- Previous update was at 11:53 AM ----------

SYNTAX ERROR

./mail_test.sh: line 11: syntax error near unexpected token `cat'
./mail_test.sh: line 11: `$ ( cat msg ; uuencode /arbor/fx1/rraj/s1.csv ) | mailx -s hello abc@xyz.com'

Did you try along with $ ? I used $ to indicate terminal, for subject field if you put double quotes its well and good.

Can you please show the example by modifying my code.

On terminal

cat >msg<<EOF
your msg
EOF
(cat msg; uuencode  path/to/your/attachement/file) | mailx -s "Your Subject" abc@xyz.com

OR

cat <<EOF | ( cat -; uuencode  path/to/your/attachement/file) | mailx -s "Your Subject" abc@xyz.com
your msg
EOF
1 Like

Yes got it thanks.

Can you also show me an example of sending 2 csv files s1.csv and s2.csv.
I mean in a script as i want to automate the process.This is my first time with mailx command:D

Just try :

(cat msg; uuencode  path/to/your/attachement/file1  path/to/your/attachement/file2  ) | mailx -s "Your Subject" abc@xyz.com

cat <<EOF | ( cat -; uuencode  /arbor/fx1/rraj/s1.csv /arbor/fx1/rraj/s2.csv) | mailx -s "Activity Log" abc@xyz.com
Hello !!!

How are you?PFA for the file.

Regards
Rahul
EOF

I am getting only one attachment .Alos i am getting the attachment in email by some other name.
I want to recieve both the attachment by same name .

Please help me out.

Some other name ?

OR try like this with semicolon

( cat -; uuencode  /arbor/fx1/rraj/s1.csv; uuencode /arbor/fx1/rraj/s2.csv ) | mailx -s "Activity Log" abc@xyz.com
1 Like