跳到主要内容

如何在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.然后出现“输出文件夹树”对话框。 请点击 USB MIDI(XNUMX通道) 按钮或 没有 按钮,根据需要。

现在一个名为的文本文件 展望文件夹 创建并保存在您的桌面上,如下图所示。

5.双击打开新的文本文件,然后单击 文件 > 打印 打印Outlook文件夹的导出列表。

一键式显示Outlook导航窗格上所有文件夹中的项目总数

通常,Outlook 会在导航窗格上显示每个文件夹中未读项目的数量。但是,Outlook的Kutools 所有文件夹显示项目总数 功能可以帮助您一键显示所有文件夹中的项目总数。


所有文件夹显示总数kto 9.00

相关文章


最佳办公生产力工具

Kutools for Outlook - 超过 100 种强大功能可增强您的 Outlook

🤖 人工智能邮件助手: 具有人工智能魔力的即时专业电子邮件——一键天才回复、完美语气、多语言掌握。轻松改变电子邮件! ...

📧 电子邮件自动化: 外出(适用于 POP 和 IMAP)  /  安排发送电子邮件  /  发送电子邮件时按规则自动抄送/密件抄送  /  自动转发(高级规则)   /  自动添加问候语   /  自动将多收件人电子邮件拆分为单独的消息 ...

📨 电子邮件管理: 轻松回忆电子邮件  /  按主题和其他人阻止诈骗电子邮件  /  删除重复的电子邮件  /  高级搜索  /  合并文件夹 ...

📁 附件专业版批量保存  /  批量分离  /  批量压缩  /  自动保存   /  自动分离  /  自动压缩 ...

🌟 界面魔法: 😊更多又漂亮又酷的表情符号   /  使用选项卡式视图提高 Outlook 工作效率  /  最小化 Outlook 而不是关闭 ...

👍 一键奇迹: 使用传入附件回复全部  /   反网络钓鱼电子邮件  /  🕘显示发件人的时区 ...

👩🏼‍🤝‍👩🏻 通讯录和日历: 从选定的电子邮件中批量添加联系人  /  将联系人组拆分为各个组  /  删除生日提醒 ...

超过 100特点 等待您的探索! 单击此处了解更多。

了解更多       免费下载      购买
 

 

Comments (3)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Thank you so much for this very valuable post. It really helped me a lot as outlook is still not able to show the folder structure!
This comment was minimized by the moderator on the site
Saved us a ton of time. Thanks for the detailed instructions. Worked like a charm! :)
Rated 5 out of 5
This comment was minimized by the moderator on the site
Most excellent tip. Thank you!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations