Monday, January 30, 2012

Generating & sending email based excel reporting as attachment

Here is a sample demonstration of generating excel based oracle query report and send it via email as attachment.
Following query would generate an excel file.
$ORACLE_HOME/bin/sqlplus -s / as sysdba << EOF

set feedback off;
set feed off markup html on spool on
spool report.xls

select * from dba_data_files;

spool off
set markup html off spool off

I’m working on Unix, redirecting script output to a file.
uuencode /home/oracle/report.xls report.xls > /home/oracle/out.mail

and then send that output as an attachment , following is an example.

mail -s "DB REPORT" <./home/oracle/out.mail

This would send email as an attachment.

No comments: