如何批量添加PST文件

更新时间:2024-08-16 19:31:36

Question: 由于公司邮箱的服务器容量小,导致每个季度都存档了很多的PST文件,在重装系统或者新建邮箱配置文件后每次都要手动添加PST文件,但是在outlook客户端只能一个一个的添加,效率很低,请问如何能够批量添加本地的PST文件?
Reply: 您可以在Outlook里边按alt+F11,打开VBA编辑器,输入以下代码(第二行的E:\\替换为您存放pst的位置)并运行BatchOpenMultiplePSTFiles()这个宏 Sub BatchOpenMultiplePSTFiles() Call LoopFolders("E:\\") MsgBox "Open Successfully!", vbExclamation + vbOKOnly, "Open Outlook Data File" End Sub Sub LoopFolders(strPath As String) Dim objFileSystem As Object Dim objFolder As Object Dim objFile As Object Dim objPSTFile As Object Set objFileSystem = CreateObject("Scripting.FileSystemObject") Set objFolder = objFileSystem.GetFolder(strPath) For Each objFile In objFolder.Files strFileExtension = objFileSystem.GetExtensionName(objFile) If LCase(strFileExtension) = "pst" Then Set objPSTFile = objFile Outlook.Application.Session.AddStore (objPSTFile.Path) End If Next If objFolder.SubFolders.Count > 0 Then For Each objSubFolder In objFolder.SubFolders If ((objSubFolder.Attributes And 2) = 0) And ((objSubFolder.Attributes And 4) = 0) Then LoopFolders (objSubFolder.Path) End If Next End If End Sub