[英]How do I get all date related info from Outlook (Python, win32)
我正在尝试从 Python 从 Outlook 检索到的消息中获取日期相关信息,但由于某些奇怪的原因我不能。
这很奇怪,因为我可以获得有关发件人、email 正文、主题、cc、bc、附件等的所有信息,但是当涉及到 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)
Output:
>>>
================= RESTART: C:/Users/XXXXX/Desktop/email.py =================
=============================== RESTART: Shell ===============================
>>>
当 CreationTime 被注释掉时,这里会失败:
Hi,
I really think that it is weird that win32 cannot read date info
Your sincerely,
Myself
Andrew
Python 3.7 版,Outlook 2016
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.