Count Messages in mail file

I need to, based on selective mail files count the number of messages in the inbox and the number of messages in the sent folder. We are implementing a “new” mail retention policy. I need this info as supportive data to a 30day limit for the inbox and sent folder before the message is deleted.

TIA.

Ceil

Subject: Count Messages in mail file

Sub Click(Source As Button) Const viewname=“($Inbox)” ’ put your view name here

Dim session As New notessession

Dim db As notesdatabase

Dim view As notesview

Dim count As Long

Set db=session.currentdatabase

Set view=db.getview(viewname)

count=view.AllEntries.Count

Msgbox Cstr(count) & " messages in folder"

End Sub

Subject: RE: Count Messages in mail file

Thank you for the code. I will try this.

Ceil

Subject: RE: Count Messages in mail file

I’m a little late to the game, but was looking through the forum for help on doing something similar. Mixed up a little code to get the following.

Dim session As New notessession

Dim db As notesdatabase

Dim view As notesview

Dim count As Long

Dim temp As String

Dim temp2 As String

Set db=session.currentdatabase

Set db = session.CurrentDatabase

Set doc = New NotesDocument( db )

threshold = Inputbox$( "Please enter a folder docs threshold: ", “Threshold Value”, 5000 )

sendto = Inputbox$("Send result to: ", “Recipient”, session.CommonUserName)

doc.Form = “Memo”

doc.SendTo = sendto

doc.Subject = “Listing of all folders over " & threshold & " docs”

doc.SaveMessageOnSend = True

crlf$ = Chr(13) & Chr(10)

tb$=Chr(9) & Chr(9)

On Error Resume Next

Forall v In db.views

If v.IsFolder Then

Set view=db.getview(v.name)

count=view.AllEntries.Count

If count > threshold Then

temp2=v.name & " " & tb$ & Cstr(count) & " messages in folder" & crlf$

temp=temp & temp2

Call doc.ReplaceItemValue( “Body”, temp )

End If

End If

End Forall

Call doc.Send( False )

Put into a button and send to user. Will prompt for document count threshold and a recipient name to get the mail. Will then send a email message with a list of all folders above the threshold set.

Not pretty, but it works :slight_smile: