Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim c As NotesDocumentCollection
Dim cur As NotesDocument
Dim EmbeddedObjects As Variant
Dim rtitem As Variant
Dim AttFileNames List As String
Dim limit As Long
Const MB_LIMIT& = 2 'Long
limit = MB_LIMIT * 1024 * 1024
Set db = s.CurrentDatabase
Set c = db.UnprocessedDocuments
If c Is Nothing Then Exit Sub
If c.Count = 0 Then Exit Sub
Set cur = c.GetFirstDocument
Do Until cur Is Nothing
If cur.Size > limit Then 'The size of a document in bytes
'doc is larger then it should be
Set rtitem = cur.GetFirstItem( "Body" )
If Not rtitem Is Nothing Then
If Not Isnull( rtitem ) Then
If rtitem.Type = 1 Then 'is it RTF
EmbeddedObjects = rtitem.EmbeddedObjects
If Not Isempty( EmbeddedObjects ) Then
Forall eo In EmbeddedObjects
If eo.Type = 1454 Then
'It's attachment, put its name in the list
AttFileNames( Lcase( eo.Source ) ) = "1"
End If
End Forall
Call rtitem.AppendText( " " )
Call rtitem.AddNewLine( 3 )
Call rtitem.AppendText( "The document is larger then the limit of 2MB." )
Call rtitem.AddNewLine( 2 )
Call rtitem.AppendText( "The following attachments have been removed: " )
Call rtitem.AddNewLine( 1 )
Forall elem In AttFileNames
Call rtitem.AddNewLine( 1 )
Call rtitem.AddTab( 1 )
Call rtitem.AppendText( "- " )
Call rtitem.AppendText( Listtag( elem ) )
End Forall
End If
End If
End If
End If
Call cur.Save( True, False, False )
End If
Erase AttFileNames 'clean the list
Set cur = c.GetNextDocument( cur )
Loop
End Sub
|