[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.

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.

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>"

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

<td bgcolor=\'$part1\'></td></tr>

when printed in HTML mail, doesn't show up the correct color as background color that cell.

Try:

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.

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.

Ok got it..

Hope this helps you...

# 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>'

Its working now, thanks elixir, pamu for all the help.

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