以编程方式从 Outlook .pst 文件中删除密码保护

发布于 2024-10-04 12:18:03 字数 1664 浏览 9 评论 0原文

我正在开展一个项目,其中涉及阅读大量 Outlook.pst 文件。

这些文件都受密码保护,但我的密码有问题。问题在于,在 Outlook 中打开每个文件并输入密码以读取数据是一个非常繁琐的过程。

现在我在想是否有任何方法可以创建一个脚本,自动为我打开每个 .pst 文件,输入密码并在没有密码的情况下再次保存文件。

我一直在谷歌搜索,似乎没有找到任何解决我的问题的方法,看起来 MAPI Outlook.application 接口的文档很少。到目前为止,我已经看到 PowerShell 脚本使用 Excel 应用程序执行此操作,来自 technet

$comments = @' 
Script name: Remove-Password.ps1 
Created on: Tuesday, July 03, 2007 
Author: Kent Finkle 
Purpose: How can I use Windows Powershell to 
Remove the Password When Opening an Excel Spreadsheet? 
'@ 
#----------------------------------------------------- 
function Release-Ref ($ref) { 
([System.Runtime.InteropServices.Marshal]::ReleaseComObject( 
[System.__ComObject]$ref) -gt 0) 
[System.GC]::Collect() 
[System.GC]::WaitForPendingFinalizers()  
} 
#----------------------------------------------------- 
$xl = new-object -comobject excel.application 
$xl.Visible = $True 
$xl.DisplayAlerts = $False 
$wb = $xl.Workbooks.Open("C:\Scripts\Test.xls",0,$False,1,"%reTG54w") 
$wb.Password = "" 
$a = $wb.SaveAs( "C:\Scripts\Test.xls") 
$a = Release-Ref($wb) 
$a = Release-Ref($xl) 

也许我可以将其应用到 MAPI 与类似的东西

$outlook = new-object -com outlook.application;
$ns = $outlook.GetNameSpace("MAPI");
$fSaveMe = $ns.GetDefaultFolder($olFolderInbox).Folders.Item("Save Me")
$fSaveMe.Items | foreach { [void]$_.Move($ns.Folders.Item("Legal")) }

有没有人遇到过类似的问题?潜在的解决方案不一定是在 PowerShell 中,它可以是 Python、Perl、Java、C# 或任何其他语言,只要它能完成工作:)

I am working on a project which involves reading through a lot of Outlook.pst files.

These files are all password protected but I have the password in question. The problem is that it's very tedious process opening each file in Outlook and enter in the password in order to read the data.

Now I'm thinking if there is any way to create a script which opens each .pst file for me automatically, enters in the password and saves the file again without the password.

I've been googling around and don't seem to find any solution to my problem, looks like the MAPI outlook.application interface is poorly documented. So far I've seen a PowerShell script doing this with an Excel application from technet

$comments = @' 
Script name: Remove-Password.ps1 
Created on: Tuesday, July 03, 2007 
Author: Kent Finkle 
Purpose: How can I use Windows Powershell to 
Remove the Password When Opening an Excel Spreadsheet? 
'@ 
#----------------------------------------------------- 
function Release-Ref ($ref) { 
([System.Runtime.InteropServices.Marshal]::ReleaseComObject( 
[System.__ComObject]$ref) -gt 0) 
[System.GC]::Collect() 
[System.GC]::WaitForPendingFinalizers()  
} 
#----------------------------------------------------- 
$xl = new-object -comobject excel.application 
$xl.Visible = $True 
$xl.DisplayAlerts = $False 
$wb = $xl.Workbooks.Open("C:\Scripts\Test.xls",0,$False,1,"%reTG54w") 
$wb.Password = "" 
$a = $wb.SaveAs( "C:\Scripts\Test.xls") 
$a = Release-Ref($wb) 
$a = Release-Ref($xl) 

Possibly I could apply this to MAPI with something similar to this

$outlook = new-object -com outlook.application;
$ns = $outlook.GetNameSpace("MAPI");
$fSaveMe = $ns.GetDefaultFolder($olFolderInbox).Folders.Item("Save Me")
$fSaveMe.Items | foreach { [void]$_.Move($ns.Folders.Item("Legal")) }

Is there anyone that has had a similar problem ? The potential solution doesn't have to be in PowerShell, it can be in Python, Perl, Java, C# or just about anything as long as it gets the job done :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薯片软お妹 2024-10-11 12:18:03

它可以通过扩展的mapi 来完成,而扩展mapi 只能通过c(++) 或delphi 来完成。另一种选择(而且更简单)是 Redemption,它将扩展的 mapi 包装在 com 对象中。更具体地说,请参阅 RDOStores 的 AddPstStoreWithPassword 方法

It can be done with extended mapi which is only possible with c(++) or delphi. Alternative (and much easier) is Redemption which wraps extended mapi in a com object. More specifically, see the AddPstStoreWithPassword method of RDOStores

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文