sending same attachments with different mails with Django mail

Viewed 10

I'm sending mail with Django mailer

from django.core.mail import send_mail,EmailMessage

If i send one mail all is working and attachment is on mail and correctly opening in pdf.

content = template.render(context)
msg = EmailMessage(subject, content, from_email, ['mail@mail.com'])
msg.content_subtype = 'html'
msg.attach(invoice.name, invoice.read(), 'application/pdf')
msg.send()

If I want create new message with same attachment in same function

msg1 = EmailMessage(subject, content, from_email,['mail@mail.com'])
msg1.content_subtype = 'html'
msg1.attach(invoice.name, invoice.read(), 'application/pdf')
msg1.send()

mail is sent but attachment can't be opened. Can't determine why is acting like this. What would be correct way to create new Email message? enter image description here

0 Answers
Related