Can anyone please help me sending html email with dynamic contents. One way is to copy the entire html code into a variable and populate the dynamic code within it in Django
from django.core.mail import EmailMultiAlternatives
subject, from_email, to = 'hello', 'from@example.com', 'to@example.com'
text_content = 'This is an important message.'
html_content = 'This is an important message.
'
msg = EmailMultiAlternatives(subject, text_content, from_email, [to]
msg.attach_alternative(html_content, "text/html")
msg.send()