65.9K
CodeProject 正在变化。 阅读更多。
Home

如何列出您的 Outlook PST 详细信息(文件名/位置、PST(旧/新)版本、大小等)

starIconstarIconstarIconstarIconstarIcon

5.00/5 (4投票s)

2011 年 10 月 26 日

CPOL

2分钟阅读

viewsIcon

66433

downloadIcon

3949

快速显示 Outlook 中当前加载的所有 PST 详细信息的 PST

引言

您是否曾经需要获取用户加载到 Outlook 中的所有 PST 文件的完整列表?

您是否让用户备份他们自己的 PST 文件,却发现他们没有复制位于 {hidden} AppData 目录中的文件?

什么?PST 文件名与 Outlook PST 文件夹名称不匹配?

我需要将哪个文件加回来才能恢复我的 #### 文件夹?

那些仍然使用旧的 Outlook PST 格式且不知道自己距离 PST 文件损坏仅差一条消息的用户怎么办?{令人厌恶}

这个小型应用程序可以回答所有这些问题(我的用户名是什么,我的 Outlook 配置文件名,路径和 PST 文件名,PST 版本(旧/新),Outlook 中显示的内容,PST 大小以及 PST 文件创建的时间),您可以将结果复制到剪贴板。

PST_Info.jpg

背景

当我们开始更换用户电脑并需要记录每个用户正在使用的 PST 文件时,我需要像这样的工具。很简单,只需研究数据存储位置(注册表)以及如何以可读格式获取它即可。

Using the Code

首先读取注册表

' 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

获取用户名

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

获取 PST 详细信息(请参阅完整的源代码)。

RichTextBox 中添加颜色(在输入数据后)

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

RichTextBox 文本复制到剪贴板(我闪烁按钮颜色以显示数据已复制)

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

关注点

您可以引导用户进入 Outlook,但无法让他们将所有 PST 文件都保存在一个目录中。

我只是开发了这个实用程序,因为花费了许多小时来修复 Outlook PST 文件,这允许用户记录他们正在使用什么。

以下是编译后的应用程序 pst_info.exe 的校验和(在执行之前验证文件完整性,或者重新编译以确保安全)。

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

历史

  • 版本 1.0 - 发布于 2011 年 10 月 25 日
© . All rights reserved.