Google appengine将本地gif作为电子邮件附件发送 [英] Google appengine Send local gif as an email attachment

查看:219
本文介绍了Google appengine将本地gif作为电子邮件附件发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个本地gif作为电子邮件附件发送到Google appengine上。电子邮件将发送但没有附件。

I'm trying to send a local gif as an email attachment on Google appengine. The email will send but without an attachment.

message = mail.EmailMessage(sender="My image <whomever@gmail.com>",
subject="image")

message.to = "Jim <whomever@gmail.com>"

message.body = my_body_text

message.html = my_body_html

image = open('./bust.gif', 'r')

attachments=[(image.name, image.read())]

message.send()

image.close()


推荐答案

您忘了设置附件消息上的字段,并创建了一个您没有使用的本地变量。只需更改

You forgot to set the attachments field on your message, and made a local variable you didn't use instead. Simply change

attachments=[(image.name, image.read())]

message.attachments=[(image.name, image.read())]

这篇关于Google appengine将本地gif作为电子邮件附件发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆