天天看点

lotus 附件的存、 取 、删

在逛论坛的时候发现的,看到写的不错,故而摘抄了下来。希望大家共同努力!

注意:这个方法是将附件放到富文本中,然后再将富文本当做存储的介质,进行存取删的操作

取附件方法------------------------------------------

通过Notesdocument.EmabledObjects属性取得

Java代码 ​

  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 

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

拆离方法-------------------

可以用NotesEmbeddedObject这个对象的ExtractFile方法

  1. Dim rtitem As Variant  
  2. Dim fileCount As Integer  
  3. Const MAX = 100000 
  4. fileCount = 0      
  5. '...set value of doc...  
  6. Set rtitem = doc.GetFirstItem( "Body" )  
  7. If ( rtitem.Type = RICHTEXT ) Then  
  8.   Forall o In rtitem.EmbeddedObjects  
  9.     If ( o.Type = EMBED_ATTACHMENT ) _  
  10.     And ( o.FileSize > MAX ) Then  
  11.       fileCount = fileCount + 1 
  12.       Call o.ExtractFile _  
  13.       ( "c:\reports\newfile" & Cstr(fileCount) )  
  14.       Call o.Remove  
  15.       Call doc.Save( True, True )  
  16.     End If  

view pla​incopy to clipboar​dprin​t?​

  1. Dim rtitem As Variant 
  2. Dim fileCount As Integer 
  3. fileCount = 0     
  4. '...set value of doc... 
  5. Set rtitem = doc.GetFirstItem( "Body" ) 
  6. If ( rtitem.Type = RICHTEXT ) Then 
  7.   Forall o In rtitem.EmbeddedObjects 
  8.     If ( o.Type = EMBED_ATTACHMENT ) _ 
  9.     And ( o.FileSize > MAX ) Then 
  10.       Call o.ExtractFile _ 
  11.       ( "c:\reports\newfile" & Cstr(fileCount) ) 
  12.       Call o.Remove 
  13.       Call doc.Save( True, True ) 
  14.     End If 

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

再次上传附件方法-------

可使用Notesrichtextitem的EmbedObject方法上传

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

继续阅读