Python: Open Outlook Email (.msg) file in read write mode

折月煮酒 提交于 2019-12-11 13:39:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!