Outlook .MSG 和 .OFT 文件格式之间有区别吗? [英] Is there a difference between the Outlook .MSG and .OFT file formats?

查看:53
本文介绍了Outlook .MSG 和 .OFT 文件格式之间有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题有点远,但我已经花了几个小时无济于事.我有一些代码可以在网络服务器上生成电子邮件文件,并允许用户下载该电子邮件并在 Outlook 中打开它.从这里,他们可以在将电子邮件发送给一群人之前对电子邮件进行各种手动更改.

This question is somewhat of a long shot, but I've spent hours on it to no avail. I have some code that generates an email file on a webserver, and allows the user to download that email and open it in Outlook. From here, they can make various manual changes to the email before they send it to a bunch of people.

现在,我生成了一个 .OFT 文件,它基本上是一个电子邮件模板.我想要做的是生成一个 .MSG 文件,这是一封实际的电子邮件.从二进制的角度来看,这些文件格式似乎是相同的.它们具有相同的流 ID、属性和内容.

Right now, I generate a .OFT file, which is basically an email template. What I want to do is generate a .MSG file, which is an actual email. From a binary point of view, it seems these file formats are identical. They have the same Stream IDs and properties and stuff.

我的方法是首先在 Outlook 中创建一封空白电子邮件,然后将其保存到名为 Base.oft 的文件中.在我的代码中,我打开文档并修改流 ID __substg1.0_1013001E,它是 HTML 电子邮件正文的 ID.然后我保存文件并将其写出到 cilent.这非常有效.

My approach was to first create a blank email message in Outlook and then just save it to a file called Base.oft. In my code, I open the document and modify Stream ID __substg1.0_1013001E which is the ID for the HTML email body. I then save the file and write it out to the cilent. This works perfectly.

我对 MSG 格式尝试了相同的方法.我创建了一封空白电子邮件,将其保存为 Base.msg,并修改了相同的 Stream ID.如果我查看生成的文件,新主体实际上就在那里并保存了.但是,如果我打开电子邮件,正文仍然是空白的.

I tried the same approach with the MSG format. I created a blank email message, saved it as Base.msg, and modify the same Stream ID. If I look at the resulting file, the new body is actually in there and saved. However, if I open the email, the body is still blank.

更奇怪的是,如果我在 Outlook 中输入正文并将其保存到基本文件,我可以在流 0_1013001E 下看到该正文.如果我然后用不同的正文修改该流,我可以验证新正文确实保存在文件中,但是如果我在 Outlook 中打开邮件,我会看到旧的原始正文.就好像电子邮件正文以 .MSG 格式存储在文件中的不同位置,但是我查看了每个流,但找不到任何其他看起来像是电子邮件正文的内容.

What's even weirder is if I type in a body in Outlook and save that to the base file, I can see that body under stream 0_1013001E. If I then modify that stream with a different body, I can verify the new body is indeed saved in the file, but if I open the message in Outlook, I see the old, original body. It's as if the email body is stored in a different place in the file for the .MSG format, however I've looked through each stream and cannot find anything else that looks like it could be an email body.

也许 .MSG 文件被加密了,或者它们的主体以某种专有的二进制格式存储,与 .OFT 文件不同?希望有人对此有所了解,因为我在互联网上搜索并基本上没有发现这些格式.

Perhaps .MSG files are encrypted, or their bodies are stored in some proprietary binary format unlike .OFT files? Hopefully someone has some insight on this, as I scoured the Internet and found basically nothing on these formats.

更新:

似乎 .MSG 格式将主体存储在流 ID __substg1.0_10090102 - 以某种二进制形式编码(不确定是什么.)如果我删除流(或将其设置为单个 ,文件损坏.

It seems the .MSG format stores the body in Stream ID __substg1.0_10090102 - Which is encoded in some binary form (not sure what.) If I delete the stream (or set it to a single , the file becomes corrupt.

推荐答案

首先,要找到有关此主题和相关主题的更多信息,请远离原始子流编号并在 google 上搜索相应的 MAPI 属性.例如,1013 是 PR_HTML,1009 是 PR_RTF_COMPRESSED.MAPI 具有将正文从一种格式同步到另一种格式的方法.

First of all, to find more information on this and related topics, move away from raw substream numbers and google for the corresponding MAPI properties. For example, 1013 is PR_HTML and 1009 is PR_RTF_COMPRESSED. MAPI has ways of synching the body from one format to the other.

请参阅 MSDN 上的这篇文章,以全面了解所有内容- 相关的 MAPI 属性(即 .MSG 文件中的不同流").

See this article on MSDN for a good overview of all content-related MAPI properties (i.e. the different "streams" inside the .MSG file).

要编写 PR_RTF_COMPRESSED,请将流包装在 WrapCompressedStream 中.另一方面,在您的特定情况下,您可能希望避免代码中的 MAPI 依赖项,因此也许您最好找到 PR_STORE_SUPPORT_MASK 并设置 STORE_UNCOMPRESSED_RTF少量.这将允许您在 PR_RTF_COMPRESSED 子流中使用直接 RTF.或者 Outlooks 花哨的 html-wrapped-in-rtf,如果你觉得勇敢的话.

To write PR_RTF_COMPRESSED, wrap the stream inside WrapCompressedStream. On the other hand, in your particular situation you might want to avoid the MAPI-dependencies in your code, so maybe you're better off finding the PR_STORE_SUPPORT_MASK and setting the STORE_UNCOMPRESSED_RTF bit. This will allow you to use straight RTF in the PR_RTF_COMPRESSED substream. Or Outlooks fancy html-wrapped-in-rtf, if you are feeling brave.

这些东西都不适合胆小的人,但是看到您已经在处理原始的 .MSG 子流写作,我猜这是可行的.

None of this stuff is for the faint of heart, but seeing how you are already handing raw .MSG substream writing, I'm guessing it would be feasible.

这篇关于Outlook .MSG 和 .OFT 文件格式之间有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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