view folder size in outlook using a macro

J

john mcmichael

I'm trying to set up a macro that when run, allows me to see the size of all
folders in Outlook. I am using the set of code below but I can not get it to
work. I open the VBE and have the code exactly how it is shown below. Is
there something that I have missed. I would also like to have a popup box
with management recomenedations appear in the box. Is this possible? I have
next to no VBA experience and that is by biggest problem...so speak
slowly...I'm afraid I might not understand. Sorry to keep bothering people
with this, but if I can get it to fly, this will be very helpful.

Private Sub GetFolderSizes()
Dim objOutlook As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder, objUnknown As Object
Dim lngBytes As Long, intX As Integer


Set objOutlook = New Outlook.Application
Set objNS = objOutlook.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderInbox)


For intX = 1 To objFolder.Items.Count
lngBytes = lngBytes + objFolder.Items.Item(intX).Size
Next


MsgBox "Folder size is " & lngBytes & " bytes."
End Sub


Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top