Page 88 - Python rat la co ban
P. 88

14.3. Gởi email có đính kèm file





          Bạn cần sử dụng thêm class Attachment để tạo


          attachment.





           from sender import Mail, Message, Attachment




           mail = Main(...)

           msg = Message(..)

           ...



           # Open attached file and create Attachment object

           with open("photo01.jpg") as f:

               file01 = Attachment("photo01.jpg", "image/jpeg"

           , f.read())



           msg.attach(file01)



           # Send message

           mail.send(msg)






          14.4. Tìm hiểu thêm






          Bạn có thể tìm hiểu thêm về thư viện  sender  tại website
   83   84   85   86   87   88   89   90   91   92