I would like to have the Size by folder in the view, How can i write this

Some users ask me if it is possible to have the total size By folder create (in mo or ko ) . I think it is possible but i could you help me to write it ?

It is very usefull for us because all the mails is class into folders, and before archiving …

Subject: I would like to have the Size by folder in the view, How can i write this

The following will give you a total for the current view if pasted into an agent that is set to run on all documentsin the view.

If you need to display these values in an outline or similar tyou could save the vlaues into a profile document or enviroment variable and then reference the vlaue from computed text on the outline.

HTH,

Shane

Sub Initialize

Dim s As New NotesSession 

Dim db As NotesDatabase 

Dim dc As NotesDocumentcollection 

Dim doc As NotesDocument 

Dim totalSize As Long



Set db = s.CurrentDatabase 

Set dc = db.UnprocessedDocuments 

Set doc = dc.GetFirstDocument 



While Not ( doc Is Nothing )

	totalSize = totalSize + doc.Size 

	

	

	

	Set doc = dc.GetNextDocument( doc )

Wend



Msgbox "Total size for the current view is " & Chr$(13) & _

"Bytes " & Format$( totalSize , "0.0000") & Chr$(13) & _

"Kbytes " & Format$( totalSize / 1024, "0.0000") & Chr$(13) & _

"MBytes " & Format$( totalSize / 1048576, "0.0000" )  & Chr$(13) & _

"for an average total of " & Cstr( totalSize / dc.count ) & " bytes per document"

End Sub

Subject: RE: I would like to have the Size by folder in the view, How can i write this

Ok , Thanks you very much, I create the agent with this code , and for display the size of the folder , i select the folder and in the menu action SizeFolder and it display the popup size ., it’s works fine … i am very happy … thanks you

Now i would like as you say that the value is store in a outline folder but i can’t do that. can you help me for storing the value into the profile…

NF

Subject: RE: I would like to have the Size by folder in the view, How can i write this

To put the values in an outline entry… I have changed the agent as shown below to put the size values in a profile doc called DbProfile. The size values go in a field called “viewsize_” +

You then put the following macro code into the label formula of your outline entry.

The only change needed in the macro code is to put the view name (shown to you by the agent that calculates the size of the view) into the first line of the macro code.

The view name shown by the agent (and used in the profile doc) may not be the same name as your views title or alias as the agent removes all characters from the view name which cannot be used to name a field in a document (e.g. if your view has backslashes or spaces in its name the agent removes those and replaces them with an underscore).

Here is the macro code

viewname := “All”;

size := @Text( @GetProfileField(“DBProfile”; “ViewSize_” + viewName) );

viewName +

@If(

	@IsError (size);

				" (?bytes)";

	" (" + size + ")bytes"

	)

Here is the agent code

'Get View Size:

Option Public

Option Explicit

Sub Initialize

Dim w As New  NotesUIWorkspace 	

Dim s As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentcollection

Dim doc As NotesDocument

Dim profileDoc As NotesDocument 	

Dim viewName As String 	

Dim totalSize As Long



Set db = s.CurrentDatabase

Set dc = db.UnprocessedDocuments

Set doc = dc.GetFirstDocument



While Not ( doc Is Nothing )

	totalSize = totalSize + doc.Size

	Set doc = dc.GetNextDocument( doc )

Wend



viewName = w.CurrentView.View.Name 

viewName = MakeFieldSafeName( viewName )



Set profileDoc = db.GetProfileDocument("DbProfile")

Call profileDoc.ReplaceItemValue( "viewSize_" &viewName, totalSize)

Call profileDoc.Save(True, False )



Msgbox "Set value for view name: " & viewName & " of " & Cstr( totalSize )

End Sub

Function MakeFieldSafeName( newName As String) As String

Dim n As Integer 



For n = 1 To Len( newName )

	Select Case Mid$( newName, n,1)

		

	Case "A" To "Z"

		MakeFieldSafeName = MakeFieldSafeName + Mid$( newName, n,1)

		

	Case "a" To "z"

		MakeFieldSafeName = MakeFieldSafeName + Mid$( newName, n,1)

		

	Case "0" To "9"

		MakeFieldSafeName = MakeFieldSafeName + Mid$( newName, n,1)

		

	Case Else

		MakeFieldSafeName = MakeFieldSafeName + "_"

	End Select

	

Next 'n

End Function

Enjoy.

Subject: RE: I would like to have the Size by folder in the view, How can i write this

Thanks you very well … i suppose when you programming it i’ts so easy for you … …

Have an Happy Christmas Shane .

Best regards

NF