python - 如何从 Outlook(Python、win32)获取所有与日期相关的信息
问题描述
我正在尝试从 Python 从 Outlook 检索到的消息中获取与日期相关的信息,但由于某些奇怪的原因我不能。
这很奇怪,因为我可以获得有关发件人、电子邮件正文、主题、抄送、密件抄送、附件等的所有信息,但是当涉及到 SentOn、CreationTime 或 LastModificationTime 等属性时,IDLE 只会重新启动(没有任何警告、错误和异常)。
这是示例代码:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
# the inbox. You can change that number to reference
# any other folder
messages = inbox.Items
message = messages.GetLast()
rec_time = message.CreationTime
body_content = message.body
subj_line = message.subject
print(rec_time, body_content, subj_line)
输出:
>>>
================= RESTART: C:/Users/XXXXX/Desktop/email.py =================
=============================== RESTART: Shell ===============================
>>>
当 CreationTime 被注释掉时,这里是 outpoot:
Hi,
I really think that it is weird that win32 cannot read date info
Your sincerely,
Myself
Andrew
Python 3.7 版,Outlook 2016
解决方案
推荐阅读
- java - 使用 Java 流创建具有动态值的员工列表
- tabulator - 使用会计原则格式化负数的制表器
- javascript - 如何将 Props() 值传递给 setState() 以使用 ReactJs 使模态表单可编辑
- javascript - JS 中的烧瓶变量
- php - Laravel 背包 select_multiple | select2_multple 在使用一对多关系更新/编辑时中断
- git - 如何从分叉存储库中的分支手动部署 Heroku 评论应用程序?
- java - JAVA Spring Boot - existsByColumne1AndNotColumn2 Repository 查询
- python - 如何从 Python 函数返回不同计数的多个值
- cordova - 使用 Cordova 的移动应用程序中的 SSO 集成问题
- excel - 在excel中更改形状背景图片