繁体   English   中英

如何发送带有附件的电子邮件?

[英]How to send an email with attachment?

我使用xlwt创建了一个Excel工作表,该工作表与Django我想通过电子邮件作为附件发送。

response = HttpResponse(mimetype='application/ms-excel')
response['Content-Disposition'] = 'attachment; filename='Report.xls'

book = xlwt.Workbook()
sheet = book.add_sheet("Core Listings")

book.save(response)
return response

我正在使用Django EmailMessage发送电子邮件。

您应该能够从电子表格数据中在内存中创建MimeBase对象,并将该对象附加到attach方法中。 attach方法采用文件三元组或MimeBase对象。 请参阅有关MimeBase的pydoc描述示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM