Django EmailMessage how to send html message

Viewed 31

Good day,how can I send html when I use django EmailMessage

from django.shortcuts import render, HttpResponse
from django.core.mail import EmailMessage
def send_email(request):
   msg = EmailMessage(
        subject='this is the title',
        body='this is the content',
        from_email='test@gmail.com', 
        to=['anothertest@yahoo.com']
    )
    msg.attach_file('t2.xls')
    msg.send(fail_silently=False)
    return HttpResponse('OK')

I tried html_message but still not work:

 msg = EmailMessage(
            subject='this is the title',
            body='this is the content',
            from_email='test@gmail.com', 
            to=['anothertest@yahoo.com']
            html_message = '<p>this is an automated message</p>'
        )

Any friend can help ?Thanks!

0 Answers
Related