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 :)