如何在Outlook中導出並列印所有資料夾和子資料夾的清單?
一般來說,您可以按下「Ctrl」+「6」鍵來檢視Outlook導航窗格中的所有資料夾清單。但是,您無法直接列印資料夾清單。本文介紹了兩個VBA腳本,用於導出並列印Outlook中所有資料夾及其子資料夾的清單。
在新郵件中導出並列印所有Outlook資料夾及其子資料夾的清單
此方法介紹了一個VBA腳本,將指定郵件帳號的所有資料夾及其子資料夾清單導出到Outlook的新郵件中。然後,您可以輕鬆列印資料夾清單。
1. 按下「Alt」+「F11」打開Microsoft Visual Basic for Applications窗口。
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. 在彈出的「選擇文件夾」對話框中,選擇要列印其資料夾清單的郵件帳號,然後點擊「確定」。
5. 所選帳號的資料夾清單將被複製到新郵件中,如下所示。點擊「文件」>「列印」以列印資料夾清單。
6. 列印後,關閉新郵件而不保存。
在記事本中導出並列印所有Outlook資料夾及其子資料夾的清單
此方法介紹了一個VBA腳本,將指定郵件帳號的所有資料夾及其子資料夾清單從Outlook導出到記事本。然後,您可以輕鬆列印資料夾清單。
1. 按下「Alt」+「F11」打開Microsoft Visual Basic for Applications窗口。
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。在打開的「選擇文件夾」對話框中,選擇要導出和列印其資料夾清單的郵件帳號,然後點擊「確定」。
4. 將出現「輸出文件夾樹」對話框。根據是否要包含樹狀縮進,點擊「是」或「否」。
現在,一個名為「Outlook-Folders」的文字文件已創建並保存在您的桌面上,如下所示:
5. 雙擊打開新的文字文件,然後點擊「文件」>「列印」以列印導出的Outlook資料夾清單。
Outlook中的AI郵件助理:更聰明的回覆,更清晰的溝通(一鍵奇蹟!) 免費
使用Kutools for Outlook的AI郵件助理簡化您的日常Outlook任務。這個強大的工具會從您過去的郵件中學習,提供智能且準確的答覆,優化您的郵件內容,並幫助您輕鬆起草和潤色郵件。

此功能支援:
- 智能回覆:根據您過去的對話獲得量身定制、精確且隨時可用的回覆。
- 增強內容:自動優化您的郵件文字以提高清晰度和影響力。
- 輕鬆撰寫:只需提供關鍵字,讓AI處理其餘部分,並有多種寫作風格可供選擇。
- 智能擴展:通過上下文感知建議來拓展您的思路。
- 摘要生成:即時獲取長郵件的簡潔概述。
- 全球觸及:輕鬆將您的郵件翻譯成任何語言。
此功能支援:
- 智能郵件回覆
- 優化的內容
- 基於關鍵字的草稿
- 智能內容擴展
- 郵件摘要生成
- 多語言翻譯
最重要的是,此功能永遠完全免費!不要再等待了——立即下載AI郵件助理並享受吧
相關文章
最佳 Office 生產力工具
最新消息:Kutools for Outlook 推出免費版本!
體驗全新 Kutools for Outlook,擁有100+ 強大功能!立即下載!
🤖 Kutools AI :運用先進 AI 技術,輕鬆處理郵件,包括答覆、摘要、優化、擴寫、翻譯與撰寫郵件。
📧 郵件自動化:自動回覆(支援 POP 和 IMAP) / 計劃發送郵件 / 發送郵件時根據規則自動抄送密送 / 自動轉發(高級規則) / 自動新增問候語 / 自動將多收件人郵件分割為個別郵件 ...
📨 郵件管理:撤回郵件 /依主題等條件阻擋詐騙郵件 / 刪除重複郵件 / 高級搜索 / 整合文件夾 ...
📁 附件專業版:批次保存 / 批次拆離 / 批次壓縮 / 自動保存 / 自動拆離 / 自動壓縮 ...
🌟 介面魔法:😊更多精美酷炫表情符號 /重要郵件來臨提醒 / 最小化 Outlook 而非關閉 ...
👍 一鍵神技:帶附件全部答復 /反釣魚郵件 / 🕘顯示發件人時區 ...
👩🏼🤝👩🏻 聯絡人與日曆:批次從選中郵件新增聯絡人 / 將聯絡人組分割為多個組 / 移除生日提醒 ...
以您偏好的語言使用 Kutools —— 支援英語、西班牙語、德語、法語、中文及40 多種其他語言!
只需一鍵即可立即啟用 Kutools for Outlook。立即下載,提升您的效率!

