如何批量添加PST文件
更新时间:2024-08-16 19:31:36
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