Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to know how can I get the size of the default Outlook PST file by using VB.net.
I want to display this on the Main page of my project so that if the pst size exceeds 3 GB then it shows pop up message.
Thanks in Advance.

What I have tried:

.
Posted
Updated 8-Sep-17 22:46pm
v2
Comments
Richard MacCutchan 9-Sep-17 3:02am    
Use the Outlook Interpol classes.

1 solution

Assuming that you know the location of the .pst file, you can use System.IO.FileInfo, see example here: [Dotnetperls]

Maybe this will be of help finding the path of the .pst file: winapi - How to find full path of Outlook .pst file? - Stack Overflow[^]
When using the above example, be sure to add Microsoft.Office.Interop.Outlook reference first, then you should import namespace, see explanation here: Outlook is not declared[^]
 
Share this answer
 
v3
Comments
Member 10616186 9-Sep-17 4:34am    
Sir,

It shows the error

Private 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
RickZeeland 9-Sep-17 4:39am    
??? what's the error message ?
Member 10616186 9-Sep-17 4:48am    
Type 'MAPIFolder' is not defined
'Session' is not declared.
'Public ReadOnly Property Right As Integer' has no parameters and its return type cannot be indexed.
Reference to a non-shared member requires an object reference.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900