jimu 发表于 2016-12-8 18:44:50

outlook存储文件

本帖最后由 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 SDKHow can I write an Outlook PST file with headers? Preferably in .NET, though C++ or anything else would be useful tooI 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.
: Outlook Personal Folders (.pst) File Format


-----------OST:---------- Off-line Storage Table (.ost)------

[*]PST format specification
[*]Wiki article on PST and OST file formats
[*]lipff - opensource C library and tools to access the Personal Folder File (PFF) and the Offline Folder File (OFF) format. PFF is used in PAB (Personal Address Book), PST (Personal Storage Table) and OST (Offline Storage Table) files.
[*]PST file format SDK C++. Can read PST and OST files.
[*]libpst.
[*]Alioth LibPST.
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 MFCOLE2 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.


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 : Outlook Item (.msg) File Format for more information. But the simplest way is to automate Outlook. You may find the following links helpful:How to automate Outlook 2010 by using C++ in Visual Studio 2010 together with MFCC++ app automates Outlook (CppAutomateOutlook)



jimu 发表于 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.

jimu 发表于 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.





down vote
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.




jimu 发表于 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.


jimu 发表于 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 : Outlook Item (.msg) File Format for more information. But the simplest way is to automate Outlook. You may find the following links helpful:How to automate Outlook 2010 by using C++ in Visual Studio 2010 together with MFCC++ app automates Outlook (CppAutomateOutlook)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.com/Forums/en-US/55e08d19-e1ae-43fb-861c-6d0ed12c7029/open-modify-and-save-outlook-msg-file?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).

页: [1]
查看完整版本: outlook存储文件