python - Python:如何仅从 Outlook 中获取电子邮件中的最新消息
问题描述
我只想在使用 Python 3 从 Outlook 发送的电子邮件中提取最新消息,而无需通过 Re,Fw 提取。
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
print(inbox.Items[len(inbox.Items)-1].body)
解决方案
使用“Item.GetLast()”
例子:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder = outlook.Folders.Item("Your Mailbox")
inbox = folder.Folders.Item("Inbox")
msg = inbox.Items
msgs = msg.GetLast()
print(msgs)
希望这可以帮助。
推荐阅读
- php - 清除刀片 laravel 以呈现新的响应 ajax
- gremlin - 如何将具有特定类型的属性添加到 gremlinpython?
- next.js - GTM 不会在页面导航上重置 dataLayer
- c++ - 这是一个线程安全的向量,如果是这样,为什么 std::vector 的某些方法需要锁定线程安全而其他方法不需要?
- java - 我不确定,为什么我的 java 缓冲阅读器代码只读取 CSV 文件的最后一行?
- amazon-web-services - 为什么具有 ALB 自定义源的 CloudFront 分配比没有 CloudFront 的 ALB 慢?
- reactjs - React 中登录表单的条件渲染
- javascript - 使用 Firebase Auth 获取 Twitter 用户名
- azure - 无法通过自动化帐户运行我的 ps 脚本
- wpf - 找到枚举但没有找到它的值