0

I'm setting up a website for my self that send email with attachment. I used this link How to send html email with django with dynamic content in it? but when I send email according to this link, static files like my images and my css and js files didn't send with my email.

here my code :

subject, from_email, to = "WebSite Newsletter Subscribe", settings.EMAIL_HOST_USER, [instance.email]
        html_content = render_to_string('newsletter/Email.html')
        text_content = strip_tags(html_content)
        msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()`

but in this code email send with bare html and not css and js doesn't include and my images doesn't attached too. I already read this link Django 1.7: how to send emails by using an html/css file as template but according to this link, I should convert my external css and js to internal and there isn't solution for my images too. I wondet How can I solve my problem.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
Mohsen Koleyni
  • 109
  • 1
  • 1
  • 8

0 Answers0