Save, retrieve, and delete lotus attachments

Source: Internet
Author: User
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
  1. Dim db As NotesDatabase
  2. Dim view As NotesView
  3. Dim doc As NotesDocument
  4. Set db = New NotesDatabase ("SanFrancisco", "hill. nsf ")
  5. Set view = db. GetView ("All Documents ")
  6. Set doc = view. GetLastDocument
  7. If doc. HasEmbedded Then
  8. Forall o In doc. EmbeddedObjects
  9. Messagebox (o. Name)
  10. End Forall
  11. Else
  12. Messagebox "No embedded objects found"
  13. End If
View plain Copy to clipboard Print ?
  1. Dim db As NotesDatabase
  2. Dim view As NotesView
  3. Dim doc As NotesDocument
  4. Set db = New NotesDatabase ("SanFrancisco", "hill. nsf ")
  5. Set view = db. GetView ("All Documents ")
  6. Set doc = view. GetLastDocument
  7. If doc. HasEmbedded Then
  8. Forall o In doc. EmbeddedObjects
  9. Messagebox (o. Name)
  10. End Forall
  11. Else
  12. Messagebox "No embedded objects found"
  13. 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.

  1. Dim doc As NotesDocument
  2. Dim rtitem As Variant
  3. Dim fileCount As Integer
  4. Const MAX = 100000
  5. FileCount = 0
  6. '... Set value of doc...
  7. Set rtitem = doc. GetFirstItem ("Body ")
  8. If (rtitem. Type = RICHTEXT) Then
  9. Forall o In rtitem. EmbeddedObjects
  10. If (o. Type = EMBED_ATTACHMENT )_
  11. And (o. FileSize> MAX) Then
  12. FileCount = fileCount + 1
  13. Call o. ExtractFile _
  14. ("C: \ reports \ newfile" & Cstr (fileCount ))
  15. Call o. Remove
  16. Call doc. Save (True, True)
  17. End If
  18. End Forall
  19. End If
View plain Copy to clipboard Print ?
  1. Dim doc As NotesDocument
  2. Dim rtitem As Variant
  3. Dim fileCount As Integer
  4. Const MAX = 100000
  5. FileCount = 0
  6. '... Set value of doc...
  7. Set rtitem = doc. GetFirstItem ("Body ")
  8. If (rtitem. Type = RICHTEXT) Then
  9. Forall o In rtitem. EmbeddedObjects
  10. If (o. Type = EMBED_ATTACHMENT )_
  11. And (o. FileSize> MAX) Then
  12. FileCount = fileCount + 1
  13. Call o. ExtractFile _
  14. ("C: \ reports \ newfile" & Cstr (fileCount ))
  15. Call o. Remove
  16. Call doc. Save (True, True)
  17. End If
  18. End Forall
  19. 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.

  1. Dim session As New NotesSession
  2. Dim db As NotesDatabase
  3. Dim doc As NotesDocument
  4. Dim rtitem As NotesRichTextItem
  5. Dim object As NotesEmbeddedObject
  6. Set db = session. CurrentDatabase
  7. Set doc = New NotesDocument (db)
  8. Set rtitem = New NotesRichTextItem (doc, "Body ")
  9. Set object = rtitem. EmbedObject _
  10. (EMBED_ATTACHMENT, "", "c: \ jim. sam ")
  11. Doc. Form = "Main Topic"
  12. Doc. Subject = "Here's Jim's document, as an attachment"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.