For outlook 2010 we had the outlook profiles set under:- HKCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows Messaging Subsystem\\Profiles
.
Similar location for outlook 2013 is:- HKCU\\Software\\Microsoft\\Office\\15.0\\Outlook\\Profiles
.
In my program, I first look for 2013 profiles, getting an exception I look for 2010 profile location.
But this would fail if outlook is downgraded to 2010. As the registry key for outlook 2013 would still be at same place.
Any suggestions on this. Probably, if I can first get the correct version of outlook installed and then search the right key rather than using the try....except....block?
Majorly I want to list all the pst files attached to Outlook.
The PST file locations are stored in the profile sections in the registry. The officially supported API designed to access and manipulate the profile data is the IProfAdmin interface (you can play with it in OutlookSpy if you click the IProfAdmin button). PST path is stored in the PR_PST_PATH
property. Extended MAPI can only be accessed from C++ or Delphi.
You can use ProfMan (it comes with the distributable version of Redemption); ProfMan can be used from any language. The following script (VB) retrieves PST files names from all local profiles:
'Print the path to all the PST files in all profiles
PR_PST_PATH = &H6700001E
set Profiles=CreateObject("ProfMan.Profiles")
for i = 1 to Profiles.Count
set Profile = Profiles.Item(i)
set Services = Profile.Services
Debug.Print "------ Profile: " & Profile.Name & " ------"
for j = 1 to Services.Count
set Service = Services.Item(j)
If (Service.ServiceName = "MSPST MS") or (Service.ServiceName = "MSUPST MS") Then
MsgBox Service.Providers.Item(1).ProfSect.Item(PR_PST_PATH)
End If
next
next
You can also retrieve PST file names from PST stores using the Outlook Object Model (but that requires Outlook to be running, and you can only do that for the currently used profile) - use the Store.FilePath
property:
set vApp = CreateObject("Outlook.Application")
for each vStore in vApp.Session.Stores
MsgBox vStore.DisplayName & " - " & vStore.FilePath
next