5

有没有办法通过 API 调用或注册表项以编程方式查找当前用户的 Outlook .pst 文件的位置?

4

2 回答 2

5

使用Outlook Redemption,您可以使用集合迭代 VBA 中的消息存储RDOStores,可通过RDOSession.Stores属性访问。

我正在研究在开箱即用的 VBA 中做类似事情的可能性......

编辑:

显然,PST 的路径编码在 StoreId 字符串中。谷歌出现了这个

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

刚刚测试,按设计工作。

于 2008-10-13T12:09:40.193 回答
0

路径应该在以下某处:

[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows 消息子系统\Profiles\Outlook]

也许这有点帮助。

于 2008-10-12T19:17:08.443 回答