简体   繁体   中英

How can I dump emails from an Outlook .pst file into a MySQL database?

获取Outlook pst文件并将所有电子邮件导出到MySQL数据库的最简单方法是什么?

Yikes. Probably the easiest would be to open your PST in Outlook, and use

File->Import and Export, Export to a File, Comma Seperated Values (Windows)

This creates a CSV file , which you can then pull into MySQL via mysqlimport .

If you need more information besides just the contents of the messages, you will need to tap into the store directly through various exotic means.

A solution I just stumbled across is: libpst

Obviously there is still some plumbing in processing one of the converted formats into SQL, but if importing into Outlook and then exporting as CSV is not an option, libpst would be a good alternative.

Been there done that :)

Yea libpst + a 6 pack of coors light is your solution here :)

like Cheeso said, not rocket science. Dump in a big table, but what to do with the attachments is where I struggled a little. First iteration ended up dumping on disk and columnize the path to "stuff".

Iteration 2, set up a small Hadoop instance and loaded the whole shebang in Hbase. I had 600Gb of emails... little OCD but works great to this day :)

我不知道答案,但是,如果你看看谷歌电子邮件上传者(开源),他们会做阅读部分......

I would write an automation client in C# to iterate through the outlook emails, then upload each one to your database. None of this stuff is rocket science. The automation client requires Outlook to be installed and running on the machine. In other words, this approach does not involve just "reading" the PST ; automation implies the Outlook app is actually running and your code is asking the app to open the emails individually. (You need not display all the UI as you do this).

Here's a Q on how to read a PST file by automating outlook using C# . Starting with that, you then need to add the MySQL update stuff, and some good error handling. Be sure to test thoroughly before deleting the files from Outlook. If you choose to not delete, be sure to have a good indexing approach to insure idempotence.

Powershell could be good for this? Eg enum emails in a folder, create sql insert for each, append insert to batch sql script:

$olApp = New-Object -com Outlook.Application
$namespace = $olApp.GetNamespace("MAPI")
$folder = $namespace.GetDefaultFolder(1)
$folder.Items  | %{ 
    "insert into MyTable (MyCol1, MyCol2, etc) values ($_.Subject, $_.body, etc)"
} | out-file "outfile.sql" -Append

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM