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.
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:
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
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
Dim parts() As String = Split(My.User.Name, "\")
Dim username As String = parts(1)
Return username
Else
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()
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