[Solved] HTML Email output issue


 
Thread Tools Search this Thread
Operating Systems HP-UX [Solved] HTML Email output issue
# 1  
Old 08-24-2012
[Solved] HTML Email output issue

Hi All,

I am facing issue while trying to send an HTML email using my HP-UX server.

I am trying to send some color codes to be drawn in the output, but in the output the correct color is not appearing. It is appearing some shades of green all the time. I referred to w3 website for the color code. Below is the code snapshot.

Code:
if [ $val1 -gt 90 ]
then
     part1="#FF0000"
else
     part1="#008000"
fi


echo "<tr><td>FINODS</td><td>/projects</td><td align="center">$val1</td><td bgcolor=\'$part1\'></td></tr>"

Also, the color is not at appearing when i am checking the output in Microsoft Outlook client, where as wrong color is coming when i am checking mail in web client.

Please help me, let me know where i am going wrong.


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 08-24-2012 at 06:34 AM.. Reason: code tags
# 2  
Old 08-24-2012
try this...

Code:
vall=100
if [[ "$vall" -gt 90 ]]
then
     part1="#FF0000"
else
     part1="#008000"
fi

echo "<tr><td>FINODS</td><td>/projects</td><td align="center">$val1</td><td bgcolor=\'$part1\'></td></tr>"

# 3  
Old 08-24-2012
Thanks pamu for the reply. My problem is that the color codes which i am passing to the html tags are not getting interpreted properly by the browser.

It is able to do a proper comparison in that if condition and passing the intended color code as output. But color code is not displaying the intended color in output mail.

example
Code:
<td bgcolor=\'$part1\'></td></tr>

when printed in HTML mail, doesn't show up the correct color as background color that cell.
# 4  
Old 08-24-2012
Try:
Code:
echo '<tr><td>FINODS</td><td>/projects</td><td align="center">'\
"$val1"\
'</td><td bgcolor="'\
"$part1"\
'"></td></tr>'

I've escaped the newlines so that you understand the beginning and end of each group.

EDIT: I've realized that your echo should also work with minor tweaks.
Code:
echo "<tr><td>FINODS</td><td>/projects</td><td align="center">$val1</td><td bgcolor='$part1'></td></tr>"

I've removed the back-slashes before the single quotes surrounding part1. There is no need to escape the single-quotes if you have them enclosed by double-quotes. In fact, such back-slashes will be treated literally.

Last edited by elixir_sinari; 08-24-2012 at 08:40 AM..
# 5  
Old 08-24-2012
Bug

Ok got it..

Hope this helps you...

Code:
# This is for text colour
echo "<font size=10 color=blue><b>Don't be serious in life:</b></font>"

#This is for background colour
echo '<body>
<h3 style="font-family:verdana;">A heading</h3>
<p style="font-family:arial;color:red;font-size:20px;">A paragraph.</p>
</body>'


Last edited by pamu; 08-24-2012 at 08:43 AM..
# 6  
Old 08-24-2012
Its working now, thanks elixir, pamu for all the help.
Code:
echo "<tr><td>FINODS</td><td>/projects</td><td align="center">$val1</td><td bgcolor='$part1'></td></tr>

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HTML not coming while sending using email

echo "$1" > test.txt awk 'BEGIN{ FS="|" print "MIME-Version: 1.0" print "Content-Type: text/html" print "Content-Disposition: inline" print "<HTML>""<TABLE border="1"><TH>Heading1</TH><TH>Heading2</TH><TH>Heading3</TH>" } { printf "<TR>" for(i=1;i<=NF;i++) printf "<TD>%s</TD>", $i... (2 Replies)
Discussion started by: ATWC
2 Replies

2. Shell Programming and Scripting

Getting email output in single line with out space in email

I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping my code ( echo "From: $FROM" echo "To: $MAILTO" echo "CC: $CC" echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed;... (6 Replies)
Discussion started by: mirwasim
6 Replies

3. Shell Programming and Scripting

[Solved] Shell script output in HTML or with table like results and mail

Hello, Currently i have a script which will disply the results in plain text format. I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html and send that content as email. Please help me how i can do that. I am using... (10 Replies)
Discussion started by: joy lobo
10 Replies

4. Shell Programming and Scripting

SQL query output convert to HTML & send as email body

Hi , I have a sql query in the unix script ,whose output is shown below.I want to convert this output to HTML table format & send email from unix with this table as email body. p_id src_system amount 1 A 100 2 B 200 3 C ... (3 Replies)
Discussion started by: jagadeeshn04
3 Replies

5. Shell Programming and Scripting

Sending HTML Email

1) Can you please provide me with a best example of how to send an HTML email via mutt or mail or send email commands using bash shell. 2) I tried below but i am not able to get the variable values in the HTML email output. (cat <<-EOT <html> <head><title></title> </head> <body> <p>Hello,... (9 Replies)
Discussion started by: Ariean
9 Replies

6. Shell Programming and Scripting

[Solved] Sending a HTML email from cli loses formatting.

Hi, I have a .sh file, to email a report of our backups from a linux machine. It looks like this (minus a few bits): echo "HELO $host.$domain" sleep 1 echo "mail from: vdrreport@$domain" sleep 1 echo "rcpt to:$mailto" sleep 1 echo "data" sleep 1 echo "subject: $host VDR-Report... (2 Replies)
Discussion started by: cognito
2 Replies

7. Shell Programming and Scripting

[SOLVED] Read html attachment from /var/mail

Hi, I am receiving an email to the server with a html attachment. When I check the /var/mail the attachment is showing as junk characters. I want to move that html file to a particular location in that server. Please help me. Regards Neethu (4 Replies)
Discussion started by: Neethu
4 Replies

8. UNIX for Dummies Questions & Answers

Sending html email with html attachment

Hello, I have a script which is sending an html file as an attachment. #!/usr/bin/ksh export MAILTO="user@company.com" export CONTENT="/usr/tmp/file.html" export SUBJECT="EmailSubject" ( echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (0 Replies)
Discussion started by: sreenathkg
0 Replies

9. UNIX for Advanced & Expert Users

html email

To change the colour of the content in email sent through unix Hi I want to change the color of the email content sent through unix. I tried a lot and left in vain. I heard that it could be done by sending the email as HTML. But I don't how to do it. Can you all share your ideas? ... (1 Reply)
Discussion started by: sakthifire
1 Replies

10. Shell Programming and Scripting

shell send html email

I know how to send an email with sendmail in a shell script. I know how to send an email with an attachment in a script. But im trying to send an email and need to set Content-Type to text/html and insert a file as the body and not attachment. Send email with file as attachment: ... (4 Replies)
Discussion started by: Ikon
4 Replies
Login or Register to Ask a Question