Html format not working

Hi All,

I have a written a script which sents the output in html format and displays it in the foreground. But for some reason it is displaying in raw html format in outlook 2013. What could be the reason. I am pasting the script as below:-

[dba@server_1 scripts]$ cat script.sh
#!/bin/bash
. /home/dba/.bash_profile

cd /u01/session
rm created_objects.html



for DB in database_1
do

    export ORACLE_SID=$DB
    export ORACLE_HOME=`grep $DB /etc/oratab | awk -F ":" {'print$2'}`

    $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF
    set markup html on spool on
    spool /u01/session/created_objects.html
    set linesize 200
    col machine for a45
    col username for a15
    col program for a35
    set feedback off
    set head on


    SELECT count(1) AS connection_count, machine, username, osuser, program
    FROM v\$session
    WHERE type <> 'BACKGROUND'
    GROUP BY username, machine,  osuser, program
    ORDER BY connection_count DESC;


    spool off;

    EOF

done

echo >> created_objects.html

mail -s "$(echo -e "Newly Created Objects\nContent-Type: text/html")" email@mail.com < /u01/session/created_objects.html

You don't say what system you are using. If you are using Linux I suggest you look at using mailx . The Gnu version should include MIME support and may be able to work with few modifications to your script.

You say that Outlook is displaying raw html. What about other clients?

Andrew

try with sendmail

(
echo "To: me@example.com"
echo "Subject: hello"
echo "Content-Type: text/html"
echo
cat /u01/session/created_objects.html
echo
) | /usr/sbin/sendmail -t
1 Like

Hi Andrew,

I checked with other clients like yahoo and it is working fine. Only in outlook 2013 it is displaying as raw html. Linux version is as below:-

Linux server 2.6.39-400.17.1.el6uek.x86_64 #1 SMP Fri Feb 22 18:16:18 PST 2013 x86_64 x86_64 x86_64 GNU/Linux

---------- Post updated at 04:02 AM ---------- Previous update was at 03:56 AM ----------

Hi itkamaraj,

Thanks a lot. The piece of code which you shared is working. What could be the reason mail -s is not displaying in outlook 2013 in html format?

In other clients like yahoo, it is displaying in html format.

Web based email can't really avoid showing text as HTML. What else is an HTML parser going to do when HTML is jammed into it by whatever means?

I suspect jamming 'content type' into the subject doesn't actually create a valid content-type header. Assembling a valid email and giving it to your mail daemon raw is better for picky things.