Re: [問題] gmail api夾帶檔案pdf空白或毀損

看板Python作者 (談無慾)時間7年前 (2016/11/14 16:51), 編輯推噓0(003)
留言3則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《jn8029 (宅男8029)》之銘言: : 各位大神好, : 小弟剛學python一個月,很多概念都不是很懂。 : 來這裡向大家請教,希望會的人可以幫幫忙 : 以下python 3.5 code是抓gmail api網站上修改的 : (網站https://developers.google.com/gmail/api/guides/sending) : def create_message_with_attachment(bcc, subject, message_text, : file,sender=sender ): : message = MIMEMultipart() : message['bcc'] = bcc : message['from'] = sender : message['subject'] = subject : msg = MIMEText(message_text) : message.attach(msg) : content_type, encoding = mimetypes.guess_type(file) : main_type, sub_type = content_type.split('/', 1) : fp = open(file, 'rb') 兩種csv打開的方法 你選自己喜歡的吧 應該是可以寄 python 3.4 or 3.5 忘了 https://gist.github.com/Aix-Shiao/f80413657b965945bc8d7b480e4e0db0 https://gist.github.com/Aix-Shiao/8306f65dd2683cf2044d97688fe1cf1c -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.124.46.82 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1479113513.A.F0D.html

11/14 16:53, , 1F
filename='yourFile.csv'
11/14 16:53, 1F

11/14 16:54, , 2F
我覺得應該是這行只有吃到yourFile 附檔名消失了
11/14 16:54, 2F

11/14 16:54, , 3F
手邊現在都沒有PYTHON沒辦法幫你測...
11/14 16:54, 3F
文章代碼(AID): #1OANifyD (Python)
文章代碼(AID): #1OANifyD (Python)