PDA

View Full Version : [VB2010] - Percorso file/s .pst di Outlook 2010


lucausa75
28-06-2011, 18:09
Salve ragazzi,

tramite VB2010 ho la necessità di popolare una ListBox con il percorso del o dei file/s .pst relativi Outlook 2010.

In breve mi servirebbe capire come recuperare il percorso indicato nell'immagine a seguire che in questo caso è solo uno ma potrebbe anche essere maggiore:

http://img863.imageshack.us/img863/1748/28062011190734.th.png (http://imageshack.us/photo/my-images/863/28062011190734.png/)

Grazie

lucausa75
29-06-2011, 10:18
...girando un pò su internet ho trovato anche questa soluzione (http://bytes.com/topic/visual-basic-net/answers/336257-how-read-outlook-profile-find-path-psts):

Private Sub Main()
Dim o As Outlook.Application
Dim n As NameSpace
Dim f As MAPIFolder
Dim s As String
Dim x As Long
o = CreateObject("outlook.application")
n = o.GetNamespace("MAPI")
n.Logon()
For Each f In n.Folders
Debug.Print(f.Name)
s = f.StoreID
Debug.Print(s)
For x = 1 To Len(s) - 1 Step 2
Debug.Print Chr$("&H" & Mid$(s, x, 2));
Next
Debug.Print()
Next
n.Logoff()
n = Nothing
o = Nothing
End Sub
però ho degli errori nel definire queste variabili:

Dim o As Outlook.Application
Dim n As NameSpace
Dim f As MAPIFolder


Ho trovato anche quest'altra soluzione (http://www.devnewsgroups.net/officedev/t42609-path-pst-files.aspx):

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOLApp.GetNamespace("MAPI")

For Each objfolder In myNamespace.Folders
WScript.Echo("Name: " & objfolder.Name)
Next

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

ma anche in questo caso ho errori nell' assegnazione di queste variabili:

myOlApp = CreateObject("Outlook.Application")
myNamespace = myOLApp.GetNamespace("MAPI")

...qualche consiglio?