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

编程入门 行业动态 更新时间:2024-10-28 09:15:07
本文介绍了如何发送带有附件的电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用xlwt我已经创建了一个Excel表格,使用Django我想作为附件发送电子邮件。

Using xlwt I have created an Excel sheet that with Django I would like to email as an attachment.

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 发送电子邮件。

I am using Django EmailMessage to send out emails.

推荐答案

您应该能够从电子表格数据中创建内存中的MimeBase对象,在attach方法中附加该对象。 attach方法会使用文件三元组或MimeBase对象。有关MimeBase和 pydoc描述。 wordpress/2012/01/13/send-emails-using-python/rel =nofollow>一个例子。

You should be able to create a MimeBase object in memory from the spreadsheet data and attach that object in the attach method. The attach method takes the file triplet or a MimeBase object. See pydoc description about MimeBase and an example.

更多推荐

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

本文发布于:2023-05-27 19:34:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/300600.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file 'D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!