Manage Learn to apply best practices and optimize your operations.

Size and List of All File Attachments in a Mailbox

A LotusScript agent for users or administrators to run that gives the person running the agent a pop-up with the total number of attachments and approximate percent of their mailbox. It also mails the person a list of all attachments with name, size and date, sender and a doclink to the e-mail. It ignores attachments under 50,000 bytes, but this amount is programable.

In estimating the percentage of mailbox space dedicated to the attachments, I have not been able to determine compression, so I max'ed the percentage displayed at 94 % of mailbox space. I chose 94% because 94 does not sound rounded off.

The agent did crash on one mailbox, for unknown reasons, after debugging was complete. But I have personally run it in many dozen mailboxes to assist users in evaluating unnecessary attachments they were keeping.


Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dateTime As NotesDateTime
Dim item As notesItem
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument, maildoc As notesDocument
Dim j As Integer, AttachList As String, n As String, size As Double
Dim d As String, Tbytes As Double, JunkSize As Double
Dim messageLine As String
Dim a As Integer, aCount As Integer, vListType As Integer
a = 0
Tbytes = Cdbl(0)
Set db = session.CurrentDatabase
Dim dbSize As Double, Mb As Double
dbSize = Cdbl(db.Size)
Dim DBpercent As Integer, Tsize As Integer, Dsize As Integer
Dim FiftyKBtyes As Double
FiftyKbytes = Cdbl (49999)
Mb = Cdbl( 1048000 )
Dsize = Cdbl(dbSize / Mb)
Set maildoc = New NotesDocument( db )
maildoc.Form = "Memo"
REM set the new document's form so it'll be readable as a mail memo
maildoc.Subject = "E-Mail File Attachments of " + _
db.Title ' set the new document's Subject to the Tag File Name
Dim RTitemA As NotesRichTextItem, RTitem As NotesRichTextItem
Set RTitemA = New NotesRichTextItem( maildoc, "Body" )
Call rtitemA.AppendText ( "E-Mail File Attachments of " + db.Title)
Call RTItemA.AddNewLine( 2)
Call rtitemA.AppendText ( " Mailbox size is expected to be under 50 Mb. " )
Call RTItemA.AddNewLine( 2)
Call rtitemA.AppendText ( "You have a mailbox of " + Cstr(dSize) + " Mb " )
Call RTItemA.AddNewLine( 1)
Dim subjectLine As String
Set collection = db.AllDocuments
Set doc = collection.GetFirstDocument
While Not (doc Is Nothing)
If Not (doc.hasitem("Body") ) Then
Goto Next_One
End If
subjectLine = doc.Subject(0)
If doc.HasEmbedded Then
Set rtitem = doc.GetFirstItem( "Body" )
If doc.hasitem("PostedDate") Then
Set item = doc.GetFirstItem("PostedDate")
D = item.DateTimeValue.DateOnly
Elseif doc.hasitem("DeliveredDate") Then
Set item = doc.GetFirstItem("DeliveredDate")
D = item.DateTimeValue.DateOnly
Else
d = ""
End If
If rtitem.Type = RICHTEXT Then
vList = rtItem.EmbeddedObjects
vListType = Datatype ( vList )
Print Cstr(vListType) + " Data type of vList, subject = " +
SubjectLine
If vListType <> 0 Then
aCount = 0
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
n = o.name
If n Like ( "att#.eml" ) Then
size = Cdbl(o.filesize)
JunkSize = JunkSize + size
Call o.Remove
Call doc.Save( False, True )
size = Cdbl(0)
Else
size = Cdbl(o.filesize)
End If
If size > FiftyKBytes Then
If aCount = 0 Then
Call RTItemA.AddNewLine( 1)
Call RTitemA.AppendDocLink ( doc,
doc.from( 0 ) & " in " & "All Documents" )
Call RTitemA.AppendText ("Subject
line: " +doc.Subject(0) )
Call RTItemA.AddNewLine( 1)
Call RTitemA.AppendText (" From " +
doc.From(0) )
Call RTItemA.AddNewLine( 1)
End If
Call RTitemA.AppendText(" " + Cstr(size)
+ " Bytes received on " + d + _
" FileName: " + N )
Call RTItemA.AddNewLine( 1)
aCount = aCount + 1
a = a + 1
Tbytes = Tbytes + size
End If
End If
End Forall
End If
End If
End If
Next_One:
Set doc = collection.GetNextDocument (doc)
Wend
Send_End:
Dim dtemp As Double
If Cdbl(Tbytes) > Cdbl(0) Then
dtemp = Cdbl(Tbytes / Mb)
Tsize = Cint(dtemp)
Else
Tsize = 0
End If
dTemp = (TBytes * 100) / dbSize
dbPercent = Cint(dTemp)
If dbPercent > 99 Then
dbPercent = 94
End If
messageline = "You have at least " + Cstr(a) + " e-mail attachments" + _
Chr(10) + "Those of 50,000 Bytes, uncompressed, are over " + Cstr(Tsize) +
_
" Mb ." + Chr(10) + Chr(10) + _
"This is possibly " + Cstr(DBPercent) + " % of your " + Cstr(dSize) + " Mb
mailbox. "
Msgbox messageLine + Chr(10) + Chr(10) + _
"Please delete any duplicates. An e-mail lists the names." + Chr (10) + _
Chr(10) + "Junk Internet files deleted occupying " + _
Cstr( JunkSize) + " bytes." , 64, "Check File Attachments"
Call RTItemA.AddNewLine( 2)
Call rtitemA.AppendText ( " Mailbox size is expected to be under 50 Mb. " )
Call RTItemA.AddNewLine( 2)
Call rtitemA.AppendText ( "You have at least " + Cstr(a) + _
" e-mail attachments." )
Call RTItemA.AddNewLine( 1)
Call rtitemA.AppendText _
( "Those of 50,000 Bytes or more total over " + Cstr(Tsize) + " Mb " )
Call RTItemA.AddNewLine( 1)
Call rtitemA.AppendText _
( "This is " + Cstr(DBPercent) + " % of your " +Cstr(dSize) + " Mb mailbox.
" )
maildoc.SendTo = session.CommonUserName
Call maildoc.Send( False ) ' send the new document to the recipient
End Sub

Dig Deeper on Domino Resources - Part 5

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close