问题
I want to open Outlook email (msg) file in read and write mode to parse it and alter date values. To fetch (read mode) date from msg file and then replace (write mode) dummy date to msg file. I did following so far.
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\Users\abc.msg")
print msg.SentOn
I am able to get SendOn date. It means its by default in read mode. How to open it in to write mode and replace SendOn date with Dummy date. Or any other way to do so?
回答1:
SentOn property is read-only in the Outlook Object Model. You'd need Extended MAPI for that (C++ or Delphi, use OpenIMsgOnIStg, set the PR_CLIENT_SUBMIT_TIME property) or Redemption (any language):
set Session = CreateObject("Redemption.RDOSession")
set Msg = Session.GetMessageFromMsgFile("C:\Users\abc.msg")
Msg.SentOn = #5/17/2016#
Msg.Save
来源:https://stackoverflow.com/questions/37269165/python-open-outlook-email-msg-file-in-read-write-mode