Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 21925|回复: 4
打印 上一主题 下一主题

outlook存储文件

[复制链接]

437

主题

566

帖子

2381

积分

金牌会员

Rank: 6Rank: 6

积分
2381
跳转到指定楼层
楼主
发表于 2016-12-8 18:44:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jimu 于 2016-12-8 20:13 编辑

查看数据文件存储位置
账号右键 -> 打开文件位置
C:\Users\xxx\AppData\Local\Microsoft\Outlook

%localappdata%\Microsoft\Outlook

parse pst file c++

-----------PST:--------Outlook Personal Folders ----- Personal Storage Table (.pst)----
PST File Format SDK
How can I write an Outlook PST file with headers? Preferably in .NET, though C++ or anything else would be useful too
I have looked at the PST SDK by Microsoft, but it appears to be read only. The only code I have found is the CodeProject article "Writing Email to the File of the PST Format", but this code can't write e-mail headers - just body and subject.
Your best bet is to use Microsoft's Messaging API (MAPI). There's plenty of help available online, and there's a sample app called MFC Mapi that one of the Microsoft guys wrote to demonstrate how the API works.

[MS-PST]: Outlook Personal Folders (.pst) File Format



-----------OST:---------- Off-line Storage Table (.ost)------
http://stackoverflow.com/questions/466716/reading-an-outlook-2003-ost-file

-----------MSG:-----------  

http://www.fileformat.info/

Visual C++ - Parse Outlook MSG File (.msg) ( EAGetMail Installer )

Can I read/render an MSG-file in C++ using Outlook Redemption?    What is Outlook Redemption?
How to Read a MS Outlook (.msg) File Using ATL and MFC  OLE2 compound   An Introduction to Structured Storage


Yes Outlook will be installed, and it sounds like i can use the outlook objects without having to open outlook.   I would use the Outlook interop.  [COM Interop]


Reading an Outlook MSG File in C#

Outlook msg file parser DLL


The .MSG file format is well documented. So, you can parse messages on your own. See [MS-OXMSG]: Outlook Item (.msg) File Format for more information.
But the simplest way is to automate Outlook. You may find the following links helpful:




回复

使用道具 举报

437

主题

566

帖子

2381

积分

金牌会员

Rank: 6Rank: 6

积分
2381
沙发
 楼主| 发表于 2016-12-8 18:55:03 | 只看该作者
I ran into the same problem. There seems to be a bunch of commercial tools, but I was only able to find one open source tool libpst. The (limited) documentation only talks about .pst files, but it worked like a charm on both .pst and .ost files for me (Outlook 2003, I believe).

I had a few issues compiling it. It couldn't seem to find the Python::Boost lib, but the following worked:


./configure --without-boost-python --disable-python && make

No need to rename the .ost file or convert it with scanpst.exe. Something like readpst -M outlook.ost will dump all your emails into files under the current dir.
回复 支持 反对

使用道具 举报

437

主题

566

帖子

2381

积分

金牌会员

Rank: 6Rank: 6

积分
2381
板凳
 楼主| 发表于 2016-12-8 18:57:05 | 只看该作者
Rename the .ost extension to .pst and run scanpst.exe in your Office installation directory. For versions prior to Outlook 2007 this will convert your OST to a PST.




[url=]down vote[/url]

Maybe you could check Alioth LibPST. If you know C, you can probably go through the source code and make it do whatever you would like to do.




回复 支持 反对

使用道具 举报

437

主题

566

帖子

2381

积分

金牌会员

Rank: 6Rank: 6

积分
2381
地板
 楼主| 发表于 2016-12-8 19:43:33 | 只看该作者
Even though all the text is there, in plain sight, it's not as obvious to a computer program without going through the motions of parsing the file. Let me remind you that this file is actually a disk in a file, meaning it has a folder structure with file names, and so on. This is unlike other mail programs that store the raw message headers and information as a "replayable text file."

If you were trying to parse a Mozilla Thunderbird email, it would be similar to parsing a regular CSV file. Split the file by newlines, stitch together multi-line headers, observe boundaries, etc. It's a very easy, plain-text format that's easy to parse. This is the technical equivlance to writing a program in C++ and reading a plain text file.

However, in a .MSG file, you have to parse the main FAT (File Allocation Table) entry, which points to other FAT entries, which points to "directory chains" called "stores," which points to "files." Also, each "file" and "directory" may split up into pieces, and these pieces may be organized any way that the program likes. While it is basically guaranteed that the pieces will be in some predefined order, their position within the file is unpredictable without parsing the entire file.

This is roughly the same difficulty as writing a device driver to read files from a storage device. It's an entire magnitude of difficulty higher. Not to mention, the only way to parse it correctly is through a ton of binary manipulation, so you're looking at a high probability of exceeding governor limits for any decent sized email.


回复 支持 反对

使用道具 举报

437

主题

566

帖子

2381

积分

金牌会员

Rank: 6Rank: 6

积分
2381
5#
 楼主| 发表于 2016-12-8 20:13:11 | 只看该作者
------msg---------
Will you be doing this on a system that has Outlook on it, and can therefore take advantage of the outlook objects, or no?

A couple of interesting items related to this here:

http://bytes.com/topic/visual-basic-net/answers/358054-reading-outlook-msg-files

http://www.priasoft.com/products-outlook-msg-developers-api.aspx


their in binary format not text format, to read binary format you need to know the data structure of the file.


The .msg format is not documented.

The "easiest" way to read it would be to have the App that defines the
format read it, in this case Outlook.

The following site provides a plethora of information on using Outlook from..NET.
http://www.microeye.com/resources/res_outlookvsnet.htm

Outlook uses the OLE structured storage file format to write the .msg files.
To read these files you have to use the OLE api. There's a set of VB.NET
classes that wraps this API in my site:





Based on the numbers you are showing, it appears that each MAPI Property is
stored as a separate Stream. Interesting!
http://msdn.microsoft.com/library/de...properties.asp


Outlook Msg file parser dll, for retrival of information (such as sender name and address, recipieants names and address, body text, email header form outlook msg file, without using outlook. Either using mapi or ole2 to parse the structured storage file


The .MSG file format is well documented. So, you can parse messages on your own. See [MS-OXMSG]: Outlook Item (.msg) File Format for more information.
But the simplest way is to automate Outlook. You may find the following links helpful:
Outlook is a singleton, that means only one instance of the application can be run in the system. So, you can use Process.Start method for opening a .msg file.
Also the CreateItemFromTemplate method of the Application class can be used for opening .msg files. Read more about that in the How To: Create a new Outlook message based on a template article.
After opening you can use the Outlook object model for doing the required modifications. The SaveAs method of the MailItem class saves the Microsoft Outlook item to the specified path and in the format of the specified file type. If the file type is not specified, the MSG format (.msg) is used.
Be aware, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.
As a workaround, you may also consider using third-party components designed for the server-side execution.

I have just answered to your post at https://social.msdn.microsoft.co ... forum=appsforoffice . There you can find all possible ways for reading and customizing .msg files programmatically.
All formats listed on the sheet are Exchange Server Protocol Documents, not Outlook. So, you can assume all Outlook versions support them (of course, if they can connect to the corresponding Exchange server).


回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-11-25 15:29 , Processed in 0.064003 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表