开发者

Google appengine Send local gif as an email attachment

开发者 https://www.devze.com 2023-02-21 09:37 出处:网络
I\'m trying to send a local gif as an email attachment on Google appengine. The email will send but without an attachment.

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_bo开发者_运维知识库dy_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())]

to

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号