Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending HTML formatted message into Outlook 2010

Status
Not open for further replies.

Rudie123

Programmer
Feb 16, 2016
3
GB
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.
 
This is what comes in Outlook:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <FONT face=arial,times> <title> DDC Daily Checks for IRA03022 PROD 16-FEB-16 </title> </head> <body BGCOLOR=99CCFF>
<h1 align="center"><u>IRA03022: PROD</u></h1> <h2>REPORT</h2> </body> </html>
 
As far as I know mailx can't send in html format.
Is it an option to send the file as an attachment (-a option of mailx) ?
For that rename it from *.log to *.html.

Or try sendmail instead.

regards
 
Thanks, sendmail isn't installed on the server I don't think but from another server, 'mail' works fine, that does send HTML emails.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top