[英]Google appengine Send local gif as an email attachment
I'm trying to send a local gif as an email attachment on Google appengine. 我正在尝试将一个本地gif作为电子邮件附件发送到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. 你忘了设置在
attachments
上的现场message
,并让你没有改用一个局部变量。 Simply change 简单地改变
attachments=[(image.name, image.read())]
to 至
message.attachments=[(image.name, image.read())]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.