I am trying to write a python program that sends an email to me depending on some condition. I would like the value to be printed in red if it matches certain criteria and green otherwise. Below is a small snippet of my code. I'm unsure on how to add this jquery/Javascript part to it.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
me = "my@email.com"
you = "you@email.com"
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"
msg['From'] = me
msg['To'] = you
text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttp://www.python.org"
#a=0
#if a==0:
# color="blue"
#else:
# color="red"
html = """
<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>
var a=0;
if (a<2) {
$("p").css("color","red");
}
</script>
</head>
<body>
<p>Hi!<br>
How are you?<br>
Here is the <a
href='http://www.python.org'>link</a> you
wanted.
</p>
</body>
</html>
"""
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
msg.attach(part1)
msg.attach(part2)
s = smtplib.SMTP('localhost')
s.sendmail(me, you, msg.as_string())
s.quit()