python读取本地foxmail_用Python读取Foxmail导出的邮件

祝读者大人圣诞快乐^_^

工作交接,需要把一些处理过的邮件记录到数据库里面,需要记录的内容包括:附件Excel文件中的每一条记录

提报人

生效时间

其中附件和提报人希望能从Foxmail导出的邮件中读出来。

2020-12-25更新:https://blog.csdn.net/weixin_44702836/article/details/105429726​blog.csdn.net

在CSDN上找到一个例子(地址如上)。

import eml_parser

import os

with open("D:\\*******.eml", 'rb') as f:

a = f.read()

eml = eml_parser.eml_parser.decode_email_b(a, True, True)

print(eml["header"])

eml["header"]的输出如下,如果需要带姓名的邮箱,就要用print(eml["header"]['header']['from']):

'subject': '******7.28',

'from': '[email protected]',

'to': ['[email protected]', '[email protected]'],

'cc': ['[email protected]', '[email protected]', 'm@

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python的selenium库可以用于自动化测试和网页爬取等任务。要实现自动发送邮件,可以使用yagmail库。下面是一个示例代码,展示了如何使用selenium和yagmail来实现自动发送邮件的功能: ```python import time import unittest import yagmail from HTMLTestRunner import HTMLTestRunner # 定义发送邮件的函数 def send_mail(report): yag = yagmail.SMTP(user="[email protected]", password="a123456", host='smtp.126.com') subject = "主题,自动化测试报告" contents = "正文,请查看附件。" yag.send('[email protected]', subject, contents, report) print('email has send out !') if __name__ == '__main__': # 定义测试用例的目录为当前目录 test_dir = './test_case' suit = unittest.defaultTestLoader.discover(test_dir, pattern='test_*.py') # 获取当前日期和时间 now_time = time.strftime("%Y-%m-%d %H_%M_%S") html_report = './test_report/' + now_time + 'result.html' with open(html_report, 'wb') as fp: # 调用 HTMLTestRunner,运行测试用例 runner = HTMLTestRunner(stream=fp, title="百度搜索测试报告", description="运行环境:Windows 10, Chrome 浏览器" ) runner.run(suit) send_mail(html_report) # 发送报告 ``` 这段代码使用了unittest和HTMLTestRunner来运行测试用例,并生成测试报告。然后使用yagmail库发送邮件,将测试报告作为附件发送给指定的邮箱。你需要根据自己的需求修改发送邮件的相关配置,比如发件人邮箱、密码、收件人邮箱等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值