在逛論壇的時候發現的,看到寫的不錯,故而摘抄了下來。希望大家共同努力!
注意:這個方法是將附件放到富文本中,然後再將富文本當做儲存的介質,進行存取刪的操作
取附件方法------------------------------------------
通過Notesdocument.EmabledObjects屬性取得 Java代碼
- 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 />
拆離方法-------------------
可以用NotesEmbeddedObject這個對象的ExtractFile方法 Java代碼
- 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
再次上傳附件方法-------
可使用Notesrichtextitem的EmbedObject方法上傳 Java代碼
- 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"