I found out when I visited the forum that it was well written, so I excerpted it. Hope everyone can work together!
Note: This method puts attachments in rich text, and then uses rich text as the storage medium for access and deletion.
Attachment fetch method ------------------------------------------
Java code is obtained through the Notesdocument. EmabledObjects attribute
- Dim db As NotesDatabase
- Dim view As NotesView
- Dim doc As NotesDocument
- Set db = New NotesDatabase ("SanFrancisco", "hill. nsf ")
- Set view = db. GetView ("All Documents ")
- Set doc = view. GetLastDocument
- If doc. HasEmbedded Then
- Forall o In doc. EmbeddedObjects
- Messagebox (o. Name)
- End Forall
- Else
- Messagebox "No embedded objects found"
- End If
View plain
Copy to clipboard
Print
?
- Dim db As NotesDatabase
- Dim view As NotesView
- Dim doc As NotesDocument
- Set db = New NotesDatabase ("SanFrancisco", "hill. nsf ")
- Set view = db. GetView ("All Documents ")
- Set doc = view. GetLastDocument
- If doc. HasEmbedded Then
- Forall o In doc. EmbeddedObjects
- Messagebox (o. Name)
- End Forall
- Else
- Messagebox "No embedded objects found"
- End If
Dim db As NotesDatabase <br/> Dim view As NotesView <br/> Dim doc As NotesDocument <br/> Set db = New NotesDatabase ("SanFrancisco", "hill. nsf ") <br/> Set view = db. getView ("All Documents") <br/> Set doc = view. getLastDocument <br/> If doc. hasEmbedded Then <br/> Forall o In doc. embeddedObjects <br/> Messagebox (o. name) <br/> End Forall <br/> Else <br/> Messagebox "No embedded objects found" <br/> End If <br/>
Detaching method -------------------
You can use the ExtractFile method Java code of the NotesEmbeddedObject object.
- Dim doc As NotesDocument
- Dim rtitem As Variant
- Dim fileCount As Integer
- Const MAX = 100000
- FileCount = 0
- '... Set value of doc...
- Set rtitem = doc. GetFirstItem ("Body ")
- If (rtitem. Type = RICHTEXT) Then
- Forall o In rtitem. EmbeddedObjects
- If (o. Type = EMBED_ATTACHMENT )_
- And (o. FileSize> MAX) Then
- FileCount = fileCount + 1
- Call o. ExtractFile _
- ("C: \ reports \ newfile" & Cstr (fileCount ))
- Call o. Remove
- Call doc. Save (True, True)
- End If
- End Forall
- End If
View plain
Copy to clipboard
Print
?
- Dim doc As NotesDocument
- Dim rtitem As Variant
- Dim fileCount As Integer
- Const MAX = 100000
- FileCount = 0
- '... Set value of doc...
- Set rtitem = doc. GetFirstItem ("Body ")
- If (rtitem. Type = RICHTEXT) Then
- Forall o In rtitem. EmbeddedObjects
- If (o. Type = EMBED_ATTACHMENT )_
- And (o. FileSize> MAX) Then
- FileCount = fileCount + 1
- Call o. ExtractFile _
- ("C: \ reports \ newfile" & Cstr (fileCount ))
- Call o. Remove
- Call doc. Save (True, True)
- End If
- End Forall
- End If
Dim doc As NotesDocument <br/> Dim rtitem As Variant <br/> Dim fileCount As Integer <br/> Const MAX = 100000 <br/> fileCount = 0 <br/>'... set value of doc... <br/> Set rtitem = doc. getFirstItem ("Body") <br/> If (rtitem. type = RICHTEXT) Then <br/> Forall o In rtitem. embeddedObjects <br/> If (o. type = EMBED_ATTACHMENT) _ <br/> And (o. fileSize> MAX) Then <br/> fileCount = fileCount + 1 <br/> Call o. extractFile _ <br/> ("c: \ reports \ newfile" & Cstr (fileCount) <br/> Call o. remove <br/> Call doc. save (True, True) <br/> End If <br/> End Forall <br/> End If
Method for re-Uploading attachments -------
You can use the EmbedObject method of Notesrichtextitem to upload Java code.
- Dim session As New NotesSession
- Dim db As NotesDatabase
- Dim doc As NotesDocument
- Dim rtitem As NotesRichTextItem
- Dim object As NotesEmbeddedObject
- Set db = session. CurrentDatabase
- Set doc = New NotesDocument (db)
- Set rtitem = New NotesRichTextItem (doc, "Body ")
- Set object = rtitem. EmbedObject _
- (EMBED_ATTACHMENT, "", "c: \ jim. sam ")
- Doc. Form = "Main Topic"
- Doc. Subject = "Here's Jim's document, as an attachment"