send attachment and body in one mail using mailx

Hi,

Our requirement is to send an attachment and content in a single mail. I am using the below command to send attachement.

---------------------
(uuencode $exp_file $exp_file) |mailx -s "$email_subject" $EmailRecipients
--------------------

I m not able to send any message in the body.i want to send a message as well regarding the script name and other details in the body along with the attachment.

Can anyone help me to do that so that in one mail i can send the attachment and also some details regarding the script in body.

Thanks in advance

This worked for me

 
mailx -s "$email_subject" $EmailRecipients << EOM
`uuencode $exp_file $exp_file`
 
Please find the file attached
 
Message in Body goes here.............
 
EOM

To add the body, you can try this:

(printf "%s\n%s\n" "$body" "$body1"; uuencode $exp_file $exp_file) |mailx -s "$email_subject" $EmailRecipients
3 Likes
mailx -s "subject" -f "attach_file" "body"

try this one out

@sachin - I did try the way u told but still i wasnt getting the body of the mail.
@leion - thanks.. this is working.