Hi,
I am running a back end HPUX 11.11 DB server and producing a HTML file using sqlplus and sending this through mailx into Outlook 2010. My issue is that the email comes in as text and not in html format. Here are the scripts:
test.ksh
#!/bin/ksh
#set -x
# Filename :
# Author : Test
# Date : 14-Dec-2015
# Description : Reports
#
export DBNAME=$1
export TDATE=`date +%d%m%Y_%H%M%S `
export ORACLE_SID=prod
export ORACLE_HOME=`grep ${DBNAME}: /etc/oratab | awk -F: '{ print $2 }'` export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib
MAILLIST='test@xx.com'
##############################
# Run Reports #
##############################
sqlplus system/xxx@${DBNAME}<< SQLEOF
set feedback off echo off trimspool on sqlprompt ""
set serveroutput on size 1000000
spool /opt/app/oracle/admin/maint/dailychecks/html/Checks_${DBNAME}_${TDATE}.log
@/opt/app/oracle/admin/maint/dailychecks/test.sql
SQLEOF
##############################
# EMAIL Reports #
##############################
#/dev/null 2>&1
cat /opt/app/oracle/admin/maint/dailychecks/html/Checks_${DBNAME}_${TDATE}.log | tail +2 | mailx -s "Check Report for ${DBNAME}" ${MAILLIST} > /dev/null 2>&1
test.sql
DECLARE
v_date DATE;
v_bgcolour VARCHAR2(6);
v_subject VARCHAR2(150);
v_hostname VARCHAR2(30);
v_instance_name VARCHAR2(30);
BEGIN
select upper(host_name),upper(INSTANCE_NAME) into v_hostname, v_instance_name
from
v$instance;
select trunc(sysdate) into v_date from dual;
DBMS_OUTPUT.PUT_LINE('<!DOCTYPE html>');
DBMS_OUTPUT.PUT_LINE('<html>');
DBMS_OUTPUT.PUT_LINE('<head>');
DBMS_OUTPUT.PUT_LINE('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
-- DBMS_OUTPUT.PUT_LINE('MIME-Version: 1.0');
-- DBMS_OUTPUT.PUT_LINE('From: Test');
-- DBMS_OUTPUT.PUT_LINE('From: Test <xx@test.com> Reply-To: xx@test.com');
-- DBMS_OUTPUT.PUT_LINE('To: xx@test.com');
-- DBMS_OUTPUT.PUT_LINE('Subject: Checks for '||v_hostname);
-- DBMS_OUTPUT.PUT_LINE('Content-Type: text/html; charset=UTF-8;');
-- DBMS_OUTPUT.PUT_LINE('<html>');
DBMS_OUTPUT.PUT_LINE('<FONT face=arial,times>');
DBMS_OUTPUT.PUT_LINE('<title>');
DBMS_OUTPUT.PUT_LINE('DDC Daily Checks for '||v_hostname||' '||v_instance_name||' '||v_date);
DBMS_OUTPUT.PUT_LINE('</title>');
DBMS_OUTPUT.PUT_LINE('</head>');
DBMS_OUTPUT.PUT_LINE('<body BGCOLOR=99CCFF>');
DBMS_OUTPUT.PUT_LINE('<h1 align="center"><u>'||v_hostname||': '||v_instance_name||'</u></h1>');
DBMS_OUTPUT.PUT_LINE('<h2>REPORT</h2>');
DBMS_OUTPUT.PUT_LINE('</body>');
DBMS_OUTPUT.PUT_LINE('</html>');
END;
/
I've tried a few different headers but cant find the right syntax...
Thanks in advance.
I am running a back end HPUX 11.11 DB server and producing a HTML file using sqlplus and sending this through mailx into Outlook 2010. My issue is that the email comes in as text and not in html format. Here are the scripts:
test.ksh
#!/bin/ksh
#set -x
# Filename :
# Author : Test
# Date : 14-Dec-2015
# Description : Reports
#
export DBNAME=$1
export TDATE=`date +%d%m%Y_%H%M%S `
export ORACLE_SID=prod
export ORACLE_HOME=`grep ${DBNAME}: /etc/oratab | awk -F: '{ print $2 }'` export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib
MAILLIST='test@xx.com'
##############################
# Run Reports #
##############################
sqlplus system/xxx@${DBNAME}<< SQLEOF
set feedback off echo off trimspool on sqlprompt ""
set serveroutput on size 1000000
spool /opt/app/oracle/admin/maint/dailychecks/html/Checks_${DBNAME}_${TDATE}.log
@/opt/app/oracle/admin/maint/dailychecks/test.sql
SQLEOF
##############################
# EMAIL Reports #
##############################
#/dev/null 2>&1
cat /opt/app/oracle/admin/maint/dailychecks/html/Checks_${DBNAME}_${TDATE}.log | tail +2 | mailx -s "Check Report for ${DBNAME}" ${MAILLIST} > /dev/null 2>&1
test.sql
DECLARE
v_date DATE;
v_bgcolour VARCHAR2(6);
v_subject VARCHAR2(150);
v_hostname VARCHAR2(30);
v_instance_name VARCHAR2(30);
BEGIN
select upper(host_name),upper(INSTANCE_NAME) into v_hostname, v_instance_name
from
v$instance;
select trunc(sysdate) into v_date from dual;
DBMS_OUTPUT.PUT_LINE('<!DOCTYPE html>');
DBMS_OUTPUT.PUT_LINE('<html>');
DBMS_OUTPUT.PUT_LINE('<head>');
DBMS_OUTPUT.PUT_LINE('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
-- DBMS_OUTPUT.PUT_LINE('MIME-Version: 1.0');
-- DBMS_OUTPUT.PUT_LINE('From: Test');
-- DBMS_OUTPUT.PUT_LINE('From: Test <xx@test.com> Reply-To: xx@test.com');
-- DBMS_OUTPUT.PUT_LINE('To: xx@test.com');
-- DBMS_OUTPUT.PUT_LINE('Subject: Checks for '||v_hostname);
-- DBMS_OUTPUT.PUT_LINE('Content-Type: text/html; charset=UTF-8;');
-- DBMS_OUTPUT.PUT_LINE('<html>');
DBMS_OUTPUT.PUT_LINE('<FONT face=arial,times>');
DBMS_OUTPUT.PUT_LINE('<title>');
DBMS_OUTPUT.PUT_LINE('DDC Daily Checks for '||v_hostname||' '||v_instance_name||' '||v_date);
DBMS_OUTPUT.PUT_LINE('</title>');
DBMS_OUTPUT.PUT_LINE('</head>');
DBMS_OUTPUT.PUT_LINE('<body BGCOLOR=99CCFF>');
DBMS_OUTPUT.PUT_LINE('<h1 align="center"><u>'||v_hostname||': '||v_instance_name||'</u></h1>');
DBMS_OUTPUT.PUT_LINE('<h2>REPORT</h2>');
DBMS_OUTPUT.PUT_LINE('</body>');
DBMS_OUTPUT.PUT_LINE('</html>');
END;
/
I've tried a few different headers but cant find the right syntax...
Thanks in advance.