lotus 附件的存、 取 、刪

來源:互聯網
上載者:User
在逛論壇的時候發現的,看到寫的不錯,故而摘抄了下來。希望大家共同努力!
注意:這個方法是將附件放到富文本中,然後再將富文本當做儲存的介質,進行存取刪的操作
取附件方法------------------------------------------
通過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 
  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 />

拆離方法-------------------
可以用NotesEmbeddedObject這個對象的ExtractFile方法 Java代碼

  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

再次上傳附件方法-------
可使用Notesrichtextitem的EmbedObject方法上傳 Java代碼

  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" 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.