有没有办法通过API调用或注册表项以编程方式查找当前用户的Outlook .pst文件的位置?
使用Outlook Redemption,您可以使用RDOStores
集合在VBA中迭代消息存储,可通过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
刚刚测试过,按设计工作.