简体   繁体   English

如何将Outlook .pst文件中的电子邮件转储到MySQL数据库中?

[英]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 可能最容易的是在Outlook中打开你的PST,并使用

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 . 这将创建一个CSV文件 ,然后您可以通过mysqlimport将其拉入MySQL。

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 我偶然发现的一个解决方案是: 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. 显然,在将一种转换后的格式处理成SQL时仍然存在一些问题,但如果导入到Outlook然后导出为CSV不是一种选择,libpst将是一个不错的选择。

Been there done that :) 去过也做过 :)

Yea libpst + a 6 pack of coors light is your solution here :) 是的libpst + 6包coors light是你的解决方案:)

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". 第一次迭代最终转储到磁盘上并将路径列为“stuff”。

Iteration 2, set up a small Hadoop instance and loaded the whole shebang in Hbase. 迭代2,设置一个小的Hadoop实例并在Hbase中加载整个shebang。 I had 600Gb of emails... little OCD but works great to this day :) 我有600Gb的电子邮件......小强迫症但是今天效果很好:)

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

I would write an automation client in C# to iterate through the outlook emails, then upload each one to your database. 我会在C#中编写一个自动化客户端来遍历outlook电子邮件,然后将每个客户端上传到您的数据库。 None of this stuff is rocket science. 这些东西都不是火箭科学。 The automation client requires Outlook to be installed and running on the machine. 自动化客户端要求在计算机上安装并运行Outlook。 In other words, this approach does not involve just "reading" the PST ; 换句话说,这种方法不仅仅涉及“读取”PST; automation implies the Outlook app is actually running and your code is asking the app to open the emails individually. 自动化意味着Outlook应用程序实际上正在运行,您的代码要求应用程序单独打开电子邮件。 (You need not display all the UI as you do this). (您无需在执行此操作时显示所有UI)。

Here's a Q on how to read a PST file by automating outlook using C# . 这是关于如何通过使用C#自动化Outlook来读取PST文件的问题 Starting with that, you then need to add the MySQL update stuff, and some good error handling. 从那开始,您需要添加MySQL更新内容,以及一些良好的错误处理。 Be sure to test thoroughly before deleting the files from Outlook. 在从Outlook中删除文件之前,请务必进行彻底测试。 If you choose to not delete, be sure to have a good indexing approach to insure idempotence. 如果您选择不删除,请务必使用良好的索引方法来确保幂等性。

Powershell could be good for this? Powershell对此有好处吗? Eg enum emails in a folder, create sql insert for each, append insert to batch sql script: 例如,在文件夹中枚举电子邮件,为每个创建sql插件,将插入附加到批处理sql脚本:

$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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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