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

查看:480
本文介绍了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的文件中.在我的代码中,我打开文档并修改Stream ID __substg1.0_1013001E,它是HTML电子邮件正文的ID.然后,我保存文件并将其写到客户端.效果很好.

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,并修改了相同的流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文件不同的专有二进制格式存储的?希望有人对此有所了解,因为我在Internet上搜索时发现这些格式基本上没有任何内容.

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中-以某种二进制形式编码(不确定是什么).如果删除流(或将其设置为单个\0),则文件变得腐败了.

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 \0, 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天全站免登陆