如何導出和打印Outlook中所有文件夾和子文件夾的列表?
一般來說,您可以按 按Ctrl + 6 鍵以查看Outlook導航窗格中所有文件夾的列表。 但是,您無法打印文件夾列表。 本文將介紹兩個VBA腳本,以導出和打印Outlook中所有文件夾及其子文件夾的列表。
在新電子郵件中導出並打印所有Outlook文件夾及其子文件夾的列表
此方法將引入VBA,以將指定電子郵件帳戶中的所有文件夾及其子文件夾的列表導出到Outlook中的新電子郵件中,然後您可以輕鬆地打印文件夾列表。
1。 按 其他 + F11 鍵以打開“ Microsoft Visual Basic應用程序”窗口。
2。 點擊 插入 > 模塊,然後將以下VBA代碼粘貼到新的“模塊”窗口中。
VBA:在Outlook中的新電子郵件中導出文件夾和子文件夾的列表
Public gFolders As String
Public Sub GetFolderNames()
Dim oSession As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim oNewMail As Outlook.mailItem
Set oSession = Outlook.Application.GetNamespace("MAPI")
Set oFolder = oSession.PickFolder
If (oFolder Is Nothing) Then Exit Sub
ProcessFolder oFolder
Set oNewMail = Application.CreateItem(olMailItem)
oNewMail.Body = gFolders
oNewMail.Display
gFolders = ""
End Sub
Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder)
Dim i As Long
Dim oSubFolder As Outlook.MAPIFolder
Dim oFolder As Outlook.MAPIFolder
Dim sFolderPaths As String
For i = CurrentFolder.Folders.Count To 1 Step -1
Set oFolder = CurrentFolder.Folders(i)
sFolderPaths = oFolder.FolderPath
gFolders = gFolders & vbCrLf & sFolderPaths & " " & oFolder.Items.Count
Next
For Each oSubFolder In CurrentFolder.Folders
If oSubFolder.Name <> "Deleted Items" Then
ProcessFolder oSubFolder
End If
Next
End Sub
3。 按 F5 運行此VBA的關鍵。
4.在彈出的選擇文件夾對話框中,選擇您要打印其文件夾列表的電子郵件帳戶,然後單擊 OK 按鈕。 看截圖:
5.現在,將指定電子郵件帳戶的文件夾列表複製到新電子郵件中,如下圖所示。 請點擊 文件 > 列印 打印文件夾的複制列表。
6.打印後,請關閉新的電子郵件而不保存。
在記事本中導出並打印所有Outlook文件夾及其子文件夾的列表
此方法將引入VBA,以將指定電子郵件帳戶中的所有文件夾及其子文件夾的列表從Outlook導出到記事本,然後您可以輕鬆地在記事本中打印Outlook文件夾的列表。
1。 按 其他 + F11 鍵以打開“ Microsoft Visual Basic應用程序”窗口。
2。 點擊 插入 > 模塊,然後將以下VBA代碼粘貼到新的“模塊”窗口中。
VBA:將所有Outlook文件夾和子文件夾的列表從Outlook導出到記事本
Dim gFileName, gCreateTree, gBase
Public Sub ExportFolderTree()
Dim objOutlook
Dim F, Folders
Dim Result
Set objOutlook = CreateObject("Outlook.Application")
Set F = objOutlook.Session.PickFolder
If Not F Is Nothing Then
Set Folders = F.Folders
Result = MsgBox("Do you want to create tree?", vbYesNo + vbDefaultButton2 + vbApplicationModal, "Output Folder Tree")
If Result = 6 Then
gCreateTree = True
Else
gCreateTree = False
End If
gFileName = GetDesktopFolder() & "\Outlook-Folders.txt"
gBase = Len(F.FolderPath) - Len(Replace(F.FolderPath, "\", "")) + 1
WriteToATextFile (CreateFolderTree(F.FolderPath, F.Name))
LoopFolders Folders
Set F = Nothing
Set Folders = Nothing
Set objOutlook = Nothing
End If
End Sub
Private Function GetDesktopFolder()
Dim objShell
Set objShell = CreateObject("WScript.Shell")
GetDesktopFolder = objShell.SpecialFolders("Desktop")
Set objShell = Nothing
End Function
Private Sub LoopFolders(Folders)
Dim F
For Each F In Folders
WriteToATextFile (CreateFolderTree(F.FolderPath, F.Name))
LoopFolders F.Folders
Next
End Sub
Private Sub WriteToATextFile(OLKfoldername)
Dim objFSO, objTextFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(gFileName, 8, True)
objTextFile.WriteLine (OLKfoldername)
objTextFile.Close
Set objFSO = Nothing
Set objTextFile = Nothing
End Sub
Private Function CreateFolderTree(OLKfolderpath, OLKfoldername)
If gCreateTree = False Then
CreateFolderTree = Mid(OLKfolderpath, 3)
Else
Dim i, x, OLKprefix
i = Len(OLKfolderpath) - Len(Replace(OLKfolderpath, "\", ""))
For x = gBase To i
OLKprefix = OLKprefix & "-"
Next
CreateFolderTree = OLKprefix & OLKfoldername
End If
End Function
3。 按 F5 運行此VBA的關鍵。 在打開的“選擇文件夾”對話框中,接下來,請選擇要導出和打印其文件夾列表的電子郵件帳戶,然後單擊 OK 按鈕。 看截圖:
4.然後出現“輸出文件夾樹”對話框。 請點擊 是 按鈕或 沒有 按鈕,根據需要。
現在一個名為的文本文件 展望文件夾 創建並保存在您的桌面上,如下圖所示。
5.雙擊打開新的文本文件,然後單擊 文件 > 列印 打印Outlook文件夾的導出列表。
一鍵式顯示Outlook導航窗格上所有文件夾中的項目總數
通常,Outlook在導航窗格上的每個文件夾中顯示未讀項目的數量。 但是,Kutools for Outlook的 所有文件夾顯示項目總數 功能可以幫助您一鍵顯示所有文件夾中的項目總數。
相關文章
最佳辦公生產力工具
Kutools for Outlook - 超過 100 種強大的功能可增強您的 Outlook
🤖 人工智慧郵件助手: 具備人工智慧魔力的即時專業電子郵件——一鍵天才回覆、完美語調、多語言掌握。輕鬆改變電子郵件! ……
📧 電子郵件自動化: 外出(適用於 POP 和 IMAP) / 安排發送電子郵件 / 發送電子郵件時按規則自動抄送/密件副本 / 自動轉送(進階規則) / 自動添加問候語 / 自動將多收件者電子郵件拆分為單獨的訊息 ...
📨 電子郵件管理: 輕鬆回憶電子郵件 / 按主題和其他人阻止詐騙電子郵件 / 刪除重複的電子郵件 / 進階搜索 / 合併資料夾 ...
📁 附件專業版: 批量保存 / 批量分離 / 批量壓縮 / 自動保存 / 自動分離 / 自動壓縮 ...
🌟 介面魔法: 😊更多又漂亮又酷的表情符號 / 使用選項卡式視圖提高 Outlook 工作效率 / 最小化 Outlook 而不是關閉 ...
👍 一鍵奇蹟: 使用傳入附件回覆全部 / 反網路釣魚電子郵件 / 🕘顯示寄件者的時區 ...
👩🏼🤝👩🏻 通訊錄和行事曆: 從選定的電子郵件中大量新增聯絡人 / 將聯絡人群組拆分為各組 / 刪除生日提醒 ...
超過 100特點 等待您的探索! 按此處了解更多。