HTML mail formating in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HTML mail formating in UNIX
# 1  
Old 07-03-2013
HTML mail formating in UNIX

Hi i need to send mail from my Unix server i used the below code.
Code:
From: TTS.OO.Monitoring.Operations
Subject: Error
X-Mailer: htmlmail 1.0
Mime-Version: 1.0
Content-Type: text/html; charset=US-ASCII
<HTML><head><style type='text/css'>
table.altrowstable { font-family: verdana,arial,sans-serif; font-size:13px; color:#333333 }
table.altrowstable th { border-width: 2px; border-style: solid; border-color: #a9c6c9; }
table.altrowstable td { border-width: 2px; border-style: solid; border-color: #a9c6c9; }
.oddrowcolor{ background-color:#d4e3e5;}
.evenrowcolor{ background-color:#c3dde0; }
</style></head><Body>
Hi All,
 
<BR></BR>
<TABLE class='altrowstable' id='alternatecolor'>
<TR bgcolor='#FFFF99' >
<TD>
TIMESTAMP     |        ORDERNO     |          SHIP_ADV_NO        |           REASON          | EMPTY FIELDS
*******************************************************************************************************************************
2012-04-24      |       10739022730     |       1027699274      |       PersonInfoShipTO details missing        |       FirstName,LastName,
-------------------------------------------------------------------------------------------------------------------------------
2012-04-24      |       10739022730     |       1027699275      |       PersonInfoShipTO details missing        |       FirstName,LastName,
-------------------------------------------------------------------------------------------------------------------------------
2012-04-24      |       10739022730     |       1027699276      |       PersonInfoShipTO details missing        |       FirstName,LastName,
</TD></TR>
</TABLE>
<BR></BR>
 
Thanks,
</body>    </html>
Online Ops-OMS Support

my output is
Code:
Hi All, 
 

 
TIMESTAMP | ORDERNO | SHIP_ADV_NO | REASON | EMPTY FIELDS ******************************************************************************************************************************* 2012-04-24 | 10739022730 | 1027699274 | PersonInfoShipTO details missing | FirstName,LastName, ------------------------------------------------------------------------------------------------------------------------------- 2012-04-24 | 10739022730 | 1027699275 | PersonInfoShipTO details missing | FirstName,LastName, ------------------------------------------------------------------------------------------------------------------------------- 2012-04-24 | 10739022730 | 1027699276 | PersonInfoShipTO details missing | FirstName,LastName, 
 
 
 
Thanks, 
Online Ops-OMS Support 

in the output i need some formatting.I am getting the extra ----------- in the mail i just need lines one below the one.

Code:
TIMESTAMP     |        ORDERNO     |          SHIP_ADV_NO        |           REASON          | EMPTY FIELDS     
*******************************************************************************************************************************
2012-04-24          |              10739022730      |              1027699274         |              PersonInfoShipTO details missing             |                FirstName,LastName,
-------------------------------------------------------------------------------------------------------------------------------
2012-04-24          |              10739022730      |              1027699275         |              PersonInfoShipTO details missing             |                FirstName,LastName,
-------------------------------------------------------------------------------------------------------------------------------
2012-04-24          |              10739022730      |              1027699276         |              PersonInfoShipTO details missing             |                FirstName,LastName,

I need formatted output.newline inside the Body tag is not identified it seems.Please hel[p me guys.
my OS version is
SunOS wapsx001 5.10 Generic_147147-26 sun4v sparc SUNW,Sun-Fire-T200
# 2  
Old 07-03-2013
This is not clearly understandable.

where is the extra ----------- in your output.
# 3  
Old 07-03-2013
if you include the table output in td it will consider it in one column..
I consider you are extracting data from Oracle DB? IF yes please read below article

Generating HTML Reports from SQL*Plus

---------- Post updated at 03:59 PM ---------- Previous update was at 03:52 PM ----------

to add....
save below in a file say mail_body
From: TTS.OO.Monitoring.Operations
Subject: Error
X-Mailer: htmlmail 1.0
Mime-Version: 1.0
Content-Type: text/html; charset=US-ASCII

loginto sqlplus -s user/password
SET MARKUP HTML ON SPOOL ON
spool mail_body append
run the query
exit

cat mail_body|sendmail <to address>
# 4  
Old 07-03-2013
hi i am not getting the data from DB ,
i am creating text file in such a pattern (which is body of mail) to be sent as a mail.
# 5  
Old 07-03-2013
Quote:
Originally Posted by mohanalakshmi
hi i am not getting the data from DB ,
i am creating text file in such a pattern (which is body of mail) to be sent as a mail.
try something like below.. alter this to add table structure color etc..

Code:
 
awk -F"|" 'BEGIN{print "<table border=\"1\">"} NR%2{print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}'  filename

here filename is the one which contains your table data

Last edited by vidyadhar85; 07-03-2013 at 08:57 AM..
# 6  
Old 07-04-2013
hi i dunno how to run the code,if i run in the command line i am getting the below output

Code:
nawk -F"|" 'BEGIN{print "<table border=\"1\">"}NR%2{print"<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"}END{print"</table>"}' mail.txt

Code:
<table border="1">
<tr>
<td>TIMESTAMP                ORDERNO           SHIP_ADV_NO            REASON                                    Fields missing</td>
</tr>
<tr>
<td>2012-04-24      </td>
<td>       10739022730     </td>
<td>       1027699274      </td>
<td> PersonInfoShipTO details missing        </td>
<td>       FirstName,LastName,</td>
</tr>
</table>

how to run the given code.I hope the code is very useful to me thank u Smilie

---------- Post updated 07-04-13 at 07:53 AM ---------- Previous update was 07-03-13 at 07:56 AM ----------

Hi i run the code but i am getting only first two lines of output.

I am not getting entire file as a output.

What changes needs to be done.
Thank u guys.
# 7  
Old 07-17-2013
Let me try to help you.

Step 1:
Use try it yourself editor
Write your html code and see whether you receive the desired output

Step 2:
Once you confirm that Output is fine, use sendmail or mutt to send the HTML content . I prefer sendmail and here is an example

Code:
( echo "From: Mohana@XXX.com"
echo "To: Lakshmi@YYY.com"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Subject: This is a test mail"
echo ""
cat my_content.html) |/usr/sbin/sendmail -t

Coming to your problem, you have specified newline is not working. Please make a note that you are writing a html code and <br> is the tag for new line.

Hope this will help you.
This User Gave Thanks to sathyaonnuix For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk HTML Conditional Formating

I am receiving the below output in text format. The output is converted to HTML table using the code mentioned below output in text LogDate DayOfWeek/Hours _0_ _1_ _2_ _3_ _4_ _5_ _6_ _7_ _8_ _9_ _10_ _11_ _12_ _13_ _14_ _15_ _16_ ... (3 Replies)
Discussion started by: Dumpi16
3 Replies

2. Shell Programming and Scripting

HTML mail with Attachment

Hi, I am using the below code: #!/bin/ksh SUBJ="Send mail from Unix with file attachments" TO=sudha.viswanathan@jpmorgan.com CC=sudha.viswanathan@jpmorgan.com ( cat << ! To : ${TO} Subject : ${SUBJ} Cc : ${CC} ! cat << ! MIME-Version: 1.0 Content-Type: text/html `cat... (1 Reply)
Discussion started by: sudvishw
1 Replies

3. Shell Programming and Scripting

Formating output in html

Hi Guys, I was searching and landed up something here only. This is the code and I want the formatted html in email but that is not working, anybody knows the reason why? #!/bin/sh set -x DATE=`date -u` # Print beginning of webpage function html_header { cat <<END ... (5 Replies)
Discussion started by: bluemind2005
5 Replies

4. Shell Programming and Scripting

How to mail a html file.?

Hi, Can anyone tell me how to mail a html file in unix? I have a HTML file which contains a table structure, and i want this table to be created in the mail body and mail it. Does anyone have any suggestions. (3 Replies)
Discussion started by: rocky88
3 Replies

5. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

6. UNIX for Advanced & Expert Users

Mail x to HTML

Hi, i've build a script, 1: neon_script and the other 2:neon_mailing those to scripts i run with 3:neon_handmatig After that i get a mail in plain text in my mail box and i want it in html format. I already tried already a several things but nothings seems to work. Somebody got i idea how... (3 Replies)
Discussion started by: Rensen
3 Replies

7. UNIX for Dummies Questions & Answers

sending mail with html content

hi, I am new to unix. I need send html content as a mail from my sun-solaris2.6 work station. When I tried that the recipient gets it as html code with all the tags. any solutions? thanx in advance (2 Replies)
Discussion started by: gmchoudary
2 Replies

8. Shell Programming and Scripting

mail: html content

hi guys, am required to prepare a report and mail it, to make it more appealing :p i wish to have content of mail in rich text format i.e html type with mailx how to specify the content type of mail body as html? Thanks in advance!!! rishi (2 Replies)
Discussion started by: RishiPahuja
2 Replies

9. Shell Programming and Scripting

Sending mail from Unix - For html output

I have automated some checks - and I want to send a email when there is an issue. This is fine and I can send the email. However - I want to generate the email in html format so I can highlight any issues to a reader.. ie. If there is a disk space issue - then the email will highlight the... (2 Replies)
Discussion started by: frustrated1
2 Replies

10. Shell Programming and Scripting

How can I write a HTML file in UNIX and sent it as a body of a mail

Hi, How can I write a HTML file in Unix. Once I do that, I want to send this file as a body of a mail, along with writing a subject for the mail I am sending through unix. How can that be done? (0 Replies)
Discussion started by: diwa81
0 Replies
Login or Register to Ask a Question