Google appengine Send local gif as an email attachment

久未见 提交于 2019-12-07 09:39:58

问题


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()

回答1:


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())]

to

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


来源:https://stackoverflow.com/questions/5526272/google-appengine-send-local-gif-as-an-email-attachment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!