Click here to Skip to main content
15,867,453 members
Articles / Productivity Apps and Services / Microsoft Office

How to List your Outlook PST Details (file name/location, PST (old/new) version, size, etc.)

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
26 Oct 2011CPOL2 min read 63.7K   3.9K   17   10
A fast way to display the details of all PSTs currently loaded into Outlook

Introduction

Did you ever need to get a full list of PSTs a user has loaded into Outlook?

Did you let a user backup their own PSTs, only to find they didn't copy the files in the {hidden} AppData directory?

What, the PST file names don't match the Outlook PST folder names?

Which file do I need to add back in to get my #### folder?

How about users still using the old Outlook PST format and have no clue they are 1 message away from a corrupted PST {yuk}?

This small application answers all those questions (What's my user name, my Outlook profile name, the path and PST file names, PST version (old/new), what is displayed as in Outlook, PST size, and when the PST file was created), and you can copy the results to your clipboard.

PST_Info.jpg

Background

I needed a tool like this when we started replacing user's computers and needed to document what PSTs each user was using. Simple enough, just research where the data is (registry) and how to get it out in a readable format.

Using the Code

Start by reading the registry:

VB.NET
' Get user name and default Outlook profile name
Dim ProfilesRoot As String = _
"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
Dim DefaultProfileString As String = "DefaultProfile"
Dim reg As RegistryKey = Nothing
Try
  reg = Registry.CurrentUser.OpenSubKey(ProfilesRoot)
  Dim DefaultProfile_Name = reg.GetValue(DefaultProfileString, 0).ToString
  RichTextBox1.Text = " User Name:  " & GetUserName() & vbCrLf
  RichTextBox1.Text = RichTextBox1.Text & _
	" Default Outlook Profile Name:  " & DefaultProfile_Name & vbCrLf & vbCrLf
  GetPSTsForProfile(DefaultProfile_Name)
Catch ex As Exception
  ' Outlook Profile registry keys do not exist
  Me.Visible = True
  MessageBox.Show("This user does not have an Outlook profile", _
		"", MessageBoxButtons.OK, MessageBoxIcon.Stop)
  Application.Exit()
End Try

Get the user's name:

VB.NET
Function GetUserName() As String
  If TypeOf My.User.CurrentPrincipal Is  _
    Security.Principal.WindowsPrincipal Then
    ' The application is using Windows authentication.
    ' The name format is DOMAIN\USERNAME.
    Dim parts() As String = Split(My.User.Name, "\")
    Dim username As String = parts(1)
    Return username
  Else
    ' The application is using custom authentication.
    Return My.User.Name
  End If
End Function

Obtain the PST details (see the full source code).

Add color to text in the RichTextBox (after the data is entered):

VB.NET
Dim Find As Integer
Dim BeginHere As Integer = 0
Dim SLength As Integer
BeginHere = 0
Dim SearchText1 As String = "User Name:"
SLength = SearchText1.Length
Do
  Find = RichTextBox1.Find(SearchText1, BeginHere, RichTextBoxFinds.MatchCase)
  If Find > -1 Then RichTextBox1.SelectionColor = Color.Blue
  BeginHere = BeginHere + SLength
  If BeginHere > Len(RichTextBox1.Text) Then Exit Do
Loop While Find > -1
RichTextBox1.Select(Len(RichTextBox1.Text) + 1, 0)
RichTextBox1.SelectionColor = Color.Black

Copy the RichTextBox text to clipboard (I flash the button color to show the data was copied):

VB.NET
Clipboard.Clear()
Clipboard.SetText(RichTextBox1.Text, TextDataFormat.Text)
Button1.BackColor = Color.LightSalmon
Me.Update()
' wait .5 second 
System.Threading.Thread.Sleep(500)
Button1.BackColor = Color.Snow
Me.Update()

Points of Interest

You can lead a user to Outlook, but you can't make them keep their PSTs all in one directory.

I just had to develop this utility as many hours were expended repairing Outlook PSTs and this allows users to document what they are using.

Here are the check sums of the pst_info.exe compiled application (VERIFY FILE INTEGRITY PRIOR TO EXECUTING, or recompile to be on the safe side).

		MD5				SHA-1
-------------------------------- ----------------------------------------
87afb53027064cf3b9f58b47d64bd4a2 fe13b256f1b94bd5fba3bcc6ca49630a2c6732f6

History

  • Version 1.0 - Published 25 Oct 2011

License

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionOutlook 2016? Pin
Member 1287987930-Nov-16 12:49
Member 1287987930-Nov-16 12:49 
QuestionIs there a C# version of this Code? And is there a way to list *.ost files too? Pin
Gökmen BULUT17-Aug-15 20:52
Gökmen BULUT17-Aug-15 20:52 
Questionrunning under Outlook 2010 Pin
Member 1090182623-Jun-14 14:59
Member 1090182623-Jun-14 14:59 
QuestionHow to find all PST files under c:\ Pin
atifbaig16-Apr-14 10:59
atifbaig16-Apr-14 10:59 
QuestionWin7 Office 2010 Pin
Jacob Taunton28-Feb-13 20:26
Jacob Taunton28-Feb-13 20:26 
I cannot get this to work on Win7 with Office 2010. Can anyone verify if it works for them. This would be a very useful tool.

Update-
I was able to get this working with some error control

Private Function IsAPST(ByVal PSTGuid)
' Check if a valid PST file
IsAPST = False
Dim reg As RegistryKey = Nothing
Dim PSTCheckFile As String = "00033009"
reg = Registry.CurrentUser.OpenSubKey(PSTGuid)
Dim PSTGuildValue = reg.GetValue(PSTCheckFile, 0)
Try
Dim PSTCheck As Int16 = 0
For Each x In PSTGuildValue
PSTCheck = PSTCheck + Hex(x)
Next

If PSTCheck = 20 Then
IsAPST = True
End If
Catch ex As Exception

End Try

modified 1-Mar-13 3:06am.

AnswerRe: Win7 Office 2010 Pin
mllarson28-May-13 7:41
mllarson28-May-13 7:41 
QuestionPST .NET Pin
Fransoa Gole6-Dec-12 21:42
Fransoa Gole6-Dec-12 21:42 
QuestionExcellent Pin
Member 93448248-Aug-12 13:39
Member 93448248-Aug-12 13:39 
GeneralMissing Files Pin
ledtech320-May-12 8:37
ledtech320-May-12 8:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.