【selenium+Python unittest】之发送带中文附件的邮箱
2018-02-03 16:21
495 查看
完整原码如下:
import smtplib from email.mime.text import MIMEText #from email.header import Header from email.mime.multipart import MIMEMultipart smtpserver = 'smtp.126.com' usersend = 'XXX@126.com' password = 'XXX' recevier = 'XXX@qq.com' subject = '坦克世界一览' #发送的附件C:\Users\XXX\Desktop\坦克世界一览.txt sendfile = open('C:\\Users\\XXX\\Desktop\\坦克世界一览.txt','rb').read() att = MIMEText(sendfile,'base64','utf-8') att['Content-Type'] = 'application/octet-stream' att.add_header('Content-Disposition', 'attachment',filename=('gb2312', '', "坦克世界一览.txt")) msg = MIMEMultipart('related') msg.attach(att) msg['Subject'] = subject msg['From'] = usersend msg['To'] = recevier smtp = smtplib.SMTP() smtp.connect(smtpserver) smtp.login(usersend,password) smtp.sendmail(usersend,recevier,msg.as_string()) smtp.quit()
相关文章推荐
- python:自动压缩指定文件夹作为附件发送邮件到指定邮箱
- Python 发送带有中文附件的邮件
- Python+selenium之简单介绍unittest单元测试框架
- selenium-Python之unittest(四)
- Python UnitTest 文档中文翻译-4(渣翻自娱)
- Python+Selenium框架-unittest执行脚本方法之addTest
- python selenium 使用unittest 示例
- Python UnitTest 文档中文翻译-7(渣翻自娱)
- Python3.4 邮件发送(含带中文附件)
- python3.5+selenium3.4自动化测试9_selenium框架2.0-unittest(上)
- selenium-webdriver(python) (十六) --unittest 框架
- 【Python】Unittest,DDT,Selenium测试百度搜索
- Selenium with Python 010 - unittest 框架(又称PyUnit 框架)
- Python 自动查询 12306 余票并发送邮箱提醒 (selenium)
- Python+Selenium框架设计篇之9-unittest执行脚本方法之makeSuite()
- selenium-Python之unittest(一)
- python+selenium的unittest框架通过读取properties文件自定义选择IE/Firefox/Chrome浏览器
- selenium-python编写unittest运行代码时候不执行
- selenium2+python3自动化2-csdn写博客(邮件发送附件测试报告)