Manage Learn to apply best practices and optimize your operations.

Remove attachment

This agent allows you to remove an attachment from a document. If you use the example in the Remove method under NotesEmbeddedObject in the help database, you will get an error if the object you are looking for does not exist. To get around this, the agent first creates an array of filenames of all attachments in the document. The agent then steps through the array of filenames and if the filename exists in the richtext field it is deleted. The error from the example will not happen in the agent because we're only looking for filenames that we know exist.
Dim s As NotesSession
Dim doc As NotesDocument
Dim db As NotesDatabase
Dim obj As NotesEmbeddedObject
Dim rt As NotesRichTextItem
Dim attachNames As Variant
Dim i As Integer
Set s = New NotesSession
set doc = ......
' ---  create array of filenames of all the attachments in the document
i = 0
Redim attachNames(i)
Forall x In doc.items
  If = "$FILE" Then
    attachNames(i) = x.values(0)
    i = i + 1
    Redim Preserve attachNames(i)
  End If
End Forall
If i > 0 Then
  Redim Preserve attachNames(i-1)
End If
' ---  for all of the filenames in attachNames, if it exists in the rich text field, remove it	
If doc.hasItem("body") Then
  Set rt = doc.GetFirstItem("body")
End If
If attachNames(0) <> "" Then
  Forall x In attachNames 
    Set obj = rt.GetEmbeddedObject( x )
    If Not( obj Is Nothing ) Then
      If ( obj.Type = EMBED_ATTACHMENT ) Then
        Call obj.Remove 
      End If
    End If
  End Forall
End If
Call, False)

Dig Deeper on Domino Resources - Part 5



  • iSeries tutorials'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 ...