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.

4
  • Possible duplicate of Django 1.7: how to send emails by using an html/css file as template Commented Jan 15, 2019 at 8:44
  • 1
    @mikirinRoman I read this link and it isn't help me Commented Jan 15, 2019 at 8:53
  • I've never had such problems, do you use absolute paths for all resources? Commented Jan 15, 2019 at 10:29
  • @mikirinRoman yes Commented Jan 15, 2019 at 10:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.