确定outlook文件夹中电子邮件的大小?

时间:2016-04-22 08:32:23

标签: vba outlook

我需要在我的邮箱中进行一些清理,我想知道VBA中是否有功能可以让我在文件夹中获取电子邮件的大小?

我将创建一个宏来解析所有文件夹,并获取每个文件夹和子文件夹中的大小,以查看空间浪费的位置。

1 个答案:

答案 0 :(得分:3)

尝试这样的事情:

Public Sub PrintFolderSizes()

Dim ns As NameSpace
Dim folder As MAPIFolder

Set ns = GetNamespace("MAPI")

For Each folder In ns.Folders
    ProcessFolder folder
Next

End Sub

Private Sub ProcessFolder(folder As MAPIFolder)

Dim folder2 As MAPIFolder
Dim obj As Object
Dim size As Double

If Not folder.Items Is Nothing Then
    For Each obj In folder.Items
        size = size + obj.size
    Next
End If

Debug.Print folder.Name & " - " & size

For Each folder2 In folder.Folders
    ProcessFolder folder2
Next

End Sub