5

Is there a way to programmatically find the location of the current user's Outlook .pst file(s) through an API call or registry entry?

Tomalak
  • 332,285
  • 67
  • 532
  • 628
Vic
  • 935
  • 2
  • 14
  • 21

2 Answers2

5

With Outlook Redemption, you can iterate the message stores in VBA using RDOStorescollection, accessible via the RDOSession.Stores property.

I am looking into the possibility of doing something similar in out-of-the-box VBA...

EDIT:

Obviously, the path to the PST is encoded in the StoreId string. Google turned up this:

Sub PstFiles()
  Dim f As MAPIFolder

  For Each f In Session.Folders
    Debug.Print f.StoreID
    Debug.Print GetPathFromStoreID(f.StoreID)
  Next f
End Sub

Public Function GetPathFromStoreID(sStoreID As String) As String
  On Error Resume Next
  Dim i As Long
  Dim lPos As Long
  Dim sRes As String

  For i = 1 To Len(sStoreID) Step 2
    sRes = sRes & Chr("&h" & Mid$(sStoreID, i, 2))
  Next

  sRes = Replace(sRes, Chr(0), vbNullString)
  lPos = InStr(sRes, ":\")

  If lPos Then
    GetPathFromStoreID = Right$(sRes, (Len(sRes)) - (lPos - 2))
  End If
End Function

Just tested, works as designed.

Tomalak
  • 332,285
  • 67
  • 532
  • 628
  • 1
    The convenience of Redemption is that it explicitly exposes RDOPstStore.PstPath property (http://www.dimastr.com/redemption/rdostore.htm#RDOPstStore) without having to hack the store entry id. – Dmitry Streblechenko Sep 11 '14 at 21:12
0

The path should be somewhere under:

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook]

Maybe this helps a bit.

prakash
  • 58,901
  • 25
  • 93
  • 115
Node
  • 21,706
  • 2
  • 31
  • 35