Python:以读写模式打开Outlook电子邮件(.msg)文件 [英] Python: Open Outlook Email (.msg) file in read write mode

查看:981
本文介绍了Python:以读写模式打开Outlook电子邮件(.msg)文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以读写模式打开Outlook电子邮件(msg)文件以对其进行解析并更改日期值.要从味精文件中获取(读取模式)日期,然后将(写模式)虚拟日期替换为味精文件.到目前为止,我一直在关注.

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

我能够获取SendOn日期.这意味着默认情况下处于读取模式.如何以写入模式打开它,并用虚拟日期替换SendOn日期.还是其他方式?

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?

推荐答案

SentOn属性在Outlook对象模型中是只读的.为此,您需要扩展MAPI(C ++或Delphi,使用OpenIMsgOnIStg,设置PR_CLIENT_SUBMIT_TIME属性)或兑换(任何语言):

SentOn property is read-only in the Outlook Object Model. You'd need Extended MAPI for that (C++ or Delp 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

这篇关于Python:以读写模式打开Outlook电子邮件(.msg)文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆