我想以读写模式打开 Outlook 电子邮件 (msg) 文件来解析它并更改日期值。从消息文件中获取(读取模式)日期,然后将虚拟日期替换(写入模式)到消息文件中。到目前为止我已经关注了。
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\Users\abc.msg")
print msg.SentOn
我能够获取 SendOn 日期。这意味着它默认处于读取模式。如何以写入模式打开它并用虚拟日期替换 SendOn 日期。或者还有其他方法吗?
最佳答案
SentOn 属性在 Outlook 对象模型中是只读的。为此,您需要扩展 MAPI(C++ 或 Delphi、使用 OpenIMsgOnIStg、设置 PR_CLIENT_SUBMIT_TIME 属性)或赎回(任何语言):
set Session = CreateObject("Redemption.RDOSession")
set Msg = Session.GetMessageFromMsgFile("C:\Users\abc.msg")
Msg.SentOn = #5/17/2016#
Msg.Save
关于Python:以读写模式打开 Outlook 电子邮件 (.msg) 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37269165/