Click here to Skip to main content
Click here to Skip to main content

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

, 26 Oct 2011
Rate this:
Please Sign up or sign in to vote.
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:

' 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:

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):

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):

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)

About the Author

gndzero

United States United States
No Biography provided

Comments and Discussions

 
Questionrunning under Outlook 2010 PinmemberMember 1090182623-Jun-14 14:59 
QuestionHow to find all PST files under c:\ Pinmemberatifbaig16-Apr-14 10:59 
QuestionWin7 Office 2010 [modified] PinmemberJacob Taunton28-Feb-13 20:26 
AnswerRe: Win7 Office 2010 Pinmembermllarson28-May-13 7:41 
QuestionPST .NET PinmemberFransoa Gole6-Dec-12 21:42 
QuestionExcellent PinmemberMember 93448248-Aug-12 13:39 
GeneralMissing Files Pinmemberledtech320-May-12 8:37 

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

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 26 Oct 2011
Article Copyright 2011 by gndzero
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid