[Python] python MIME Multipart Messages →→→→→进入此内容的聊天室

来自 , 2019-05-12, 写在 Python, 查看 107 次.
URL http://www.code666.cn/view/65d90fc6
  1. #!/usr/bin/python
  2. from email.MIMEMultipart import MIMEMultipart
  3. import os
  4. import sys
  5.  
  6. filename = sys.argv[1]
  7.  
  8. msg = MIMEMultipart()
  9. msg['From'] = 'Me <me@example.com>'
  10. msg['To'] = 'You <you@example.com>'
  11. msg['Subject'] = 'Your picture'
  12.  
  13. from email.MIMEText import MIMEText
  14. text = MIMEText("Here's that picture I took of you.")
  15. msg.attach(text)
  16.  
  17. from email.MIMEImage import MIMEImage
  18. image = MIMEImage(open(filename).read(), name=os.path.split(filename)[1])
  19. msg.attach(image)
  20.  
  21. #//python/8047

回复 "python MIME Multipart Messages"

这儿你可以回复上面这条便签

captcha