Skip to content

Instantly share code, notes, and snippets.

@Verurteilt
Created June 23, 2013 07:19
Show Gist options
  • Save Verurteilt/5844140 to your computer and use it in GitHub Desktop.
Save Verurteilt/5844140 to your computer and use it in GitHub Desktop.
DOCX email class
def docx(request):
response = HttpResponse(content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
response['Content-Disposition'] = 'attachment; filename="archivo.docx"'
html_content = "Informacion recibida de <br><br><br>***Mensaje****<br><br>"
msg = EmailMessage('Correo de Contacto', html_content, '[email protected]', [to_admin])
file_ = open('archivo.docx', 'r+')
msg.attach('archivo.docx', file_.read(), 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')
msg.send()
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment