如何找到Outlook .pst文件的完整路径? [英] How to find full path of Outlook .pst file?

查看:360
本文介绍了如何找到Outlook .pst文件的完整路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过API调用或注册表项以编程方式找到当前用户的Outlook .pst文件的位置?

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?

推荐答案

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

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

我正在研究在现成的VBA中执行类似操作的可能性...

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

很明显,PST的路径是在StoreId字符串中编码的. Google出现了:

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.

这篇关于如何找到Outlook .pst文件的完整路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆