Thursday, September 1, 2011

Attach EmailMultiAlternatives message to an e-mail

How do I attached a EmailMultiAlternatives email as an attachment to
another e-mail? I want to create a EmailMultiAlternatives and send
it. Then I want to create another e-mail and attach the previous
email to this one.

For example:
----------------------------
parameterDict = {today:'monday', month:'june'}

txt_content = myCreateTxt( parameterDict )
html_content = myCreateHtml( parameterDict )

clientEmailMsg = EmailMultiAlternatives(xxx, myTxtHtml, ….)
clientEmailMsg.attach_alternative(html_content, "text/html")
clientEmailMsg.send()

own_contentTxt = 'created e-mail with %s'%parameterDict
own_contentHtml = '<p>created e-mail with %s</p>'%parameterDict
ownEmailMsg = EmailMultiAlternatives(xxx, own_contentTxt, ….)
ownEmailMsg.attach_alternative(own_contentHtml, "text/html")

#this is where problem happens:
ownEmailMsg.attach(clientEmailMsg)
ownEmailMsg.send()
----------------------------

I get the exception 'assert content is not None'. I assume I need to
convert ownEmailMsg to a MIMEBase but I'm not sure how.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment