I created an email template in HTML which i call in my python code. I render the mail using MIMEMultipart() and sending it afterwards via SMTP server to Microsoft Outlook. I pass a variable to my html code and want to change the color if the value of the variable is higher then 100.
For that i did that:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
</head>
<body lang=DE link=blue vlink=purple style='word-wrap:break-word'>
<script>
<div class=WordSection1>
function f_color() {
if (document.getElementById('ID').value > '100') {
document.getElementById('ID').style.color = "red";
} else {
document.getElementById('ID').style.color = "green";
}
}
document.getElementById('ID').onchange = f_color;
</script>
<div class=WordSection1>
<p class=MsoNormal>
<span lang=EN-US style='font-size:11.0pt;font-family:Calibri,sans-serif;mso-ansi-language:EN-US'>
<table id="myTable" style="width:100%">
<tr>
<td><b>{{ ID }}</b> </td>
</tr>
</table>
</span>
</p>
</div>
</body>
</html>
But it didn't change the color. I looked also in other related questions but didn't find any solution. I also didn't worked with coloring in html yet, so please indulgent.