Check attachment size before doc is saved

This tip describes how to check attachment sized before doc is saved.

Use the following code in the Querysave event to prevent saving a document that exceeds size limits you want to impose.

To avoid getting an extra prompt to save the document when the limit is exceeded, you'll either want to use the formula "@If(@Command([FileSave]);@Command([FileCloseWindow])" or use a hidden, editable "SaveOptions" field on the form, with a default text value of "1". If you use the SaveOptions field, then enable the "fieldsettext" calls in the script below.


Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim totalSize As Long

Set uidoc = ws.CurrentDocument
Set doc = uidoc.document

Call uidoc.refresh(True)
Dim rtitem As Variant
Dim embedObjs As Variant

Set rtitem = doc.getFirstItem("Body")
embedObjs = rttem.embeddedObjects
totalSize = 0
dim oneMB as long
oneMB = 1048576


If Not Isempty(embedObjs) Then
 For i = 0 To Ubound(embedObjs)
  totalSize = totalSize + embedObjs(i).
filesize
  If embedObjs(i).filesize > 2 * oneMB 
Then
     Msgbox("Your attachment '"  +
embedObjs(i).name +"' is " +Cstr(Round
     (embedObjs(i).filesize / oneMB,1)) +"    
mb. The limit is 2.0 mb.")
     continue = False
     'Call uidoc.fieldsettext
("SaveOptions","0")
   End If
 Next

 If totalSize > 4 * oneMB Then
    Msgbox("Your total attachment size is " 
+Cstr(Round (totalSize /
    oneMB,1)) +" mb.  The limit is 4.0 mb.")
    continue = False
    'Call uidoc.fieldsettext("SaveOptions","0")
  End If
End If
This was first published in February 2003

Dig deeper on LotusScript

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

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 ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close