Tally E-Mail Size for Each Folder

I’d like to create a button that will allow me to choose a folder (or group of sub-folders) and tally up the size of all the e-mails in that / those folders.

Each e-mail msg already tells you the current size of that particular msg, so surely there is a way to create a button that will add those figures up for me.

I’m drawing an absolute blank on this though. Anyone already got anything similar to this?

Subject: Here is something similar

It allows you to select documents and see the total size. So you could open a folder, select all (CTRL+A) and run the agent.

Example:

Sub Initialize

On Error Goto ErrorHandler	



Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim i As Integer

Dim message As String

Dim TotalSize As Long

Dim TotalSizeStr As String



Set db = session.CurrentDatabase

If (db Is Nothing) Then

	Message = "The database could not be opened"

	Goto endofsub

End If



Set collection = db.UnprocessedDocuments

If (collection Is Nothing) Then

	Message = "No documents were selected."

	Goto endofsub

End If



Set doc = collection.GetFirstDocument()

If (doc Is Nothing) Then

	Message = "A problem occured setting the document."

	Goto endofsub

End If



For i = 1 To collection.count

	TotalSize = TotalSize + doc.Size	

	Set doc = collection.GetNextDocument(doc)

Next



If (TotalSize) < 1024 Then

	TotalSizeStr = Format((TotalSize), "#,#") & " bytes."

Elseif (TotalSize) < 1048576 Then

	TotalSizeStr = Format((TotalSize/1024), "#,#") & " kilobytes (KB), or " & Format((TotalSize), "#,#") & " bytes."

Elseif (TotalSize) < 1073741824 Then

	TotalSizeStr = Format((TotalSize/1024/1024), "#,#")  & " megabytes (MB), or " & Format((TotalSize), "#,#") & " bytes."

Else

	TotalSizeStr = Format((TotalSize/1024/1024/1024), "#,#")  & " gigabytes (GB), or " & Format((TotalSize), "#,#") & " bytes."

End If



Message = "The total size of the " & Format(collection.count, "#,#") & " selected documents is " & TotalSizeStr

' should do a fancier size calculation, divide by 1024, round, display as bytes, Kb, or Mb

endofsub: ’ place any wrap up stuff here

Messagebox Message , 64 , "Complete"

Exit Sub	

ErrorHandler:

Messagebox "ERROR in <Initialize>: " & Str(Err) & ": " & Error$ & " on line:" & Str(Erl) , 16, "Error!!!"

Exit Sub	

End Sub

Alan Lepofsky - IBM/Lotus

Learn more at my Lotus Notes Tips and Tricks Blog

LOTs of US working together to innovate for success

Subject: RE: Here is something similar

Perfect Alan, thanks a mint. -Scott