BlueTrin
BlueTrin

Reputation: 10063

Determine the size of the emails in an outlook folder?

I need to do some cleanup in my mailbox, I was wondering if there are functions in VBA which would allow me to get the size of the emails in a folder ?

I will make a macro to parse all folders and get the size in each folder and sub folder to see where the space is wasted.

Upvotes: 3

Views: 2290

Answers (1)

steveo40
steveo40

Reputation: 931

Try something like this:

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

Upvotes: 4

Related Questions