I am generating output file (.xls format) from the below DB query-

sqlplus -S -L user/pass@DB <<EOF | sed '/^$/d' >> home/test/query_output.xls
set line 22000
set head off
set feedback off
SELECT * from table;

The query_output.xls file contains records as below-

VIM     00 34562356   22412299    Dated                                                    11-JUN-18  OMM  sansra carla     Yes No No No         02356478               14-SEP-18

To send this query_output.xls file as an attachment in email, I am using below-

uuencode home/test/ query_output.xls | mailx -s "Subject" me@Domain.com

Also tried

uuencode query_output.xls query_output.xls | mailx -s "Subject" me@Domain.com

But not getting the data in attachment received in email.

Also tried mailx -a and mutt but its showing 'illegal option -- a' and 'command not found' resp.

mailx -a home/test/query_output.xls -s "Subject" me@Domain.com < /dev/null

mutt -a query_output.xls query_output.xls < /dev/null

also tried

mailx -s "Subject" me@Domain.com < query_output.xls

but no attachment received.

Could you please help?

  • 3
    That's not an XLS format file. – roaima Jun 13 '18 at 22:42

You can send an attachment with mutt like this:

"Body of email" | mutt -a query_output.xls  -s "subject" -- me@Domain.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.