zoukankan      html  css  js  c++  java
  • 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 
    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 


    拆离方法-------------------
    可以用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 
    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 


    再次上传附件方法-------
    可使用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" 

  • 相关阅读:
    简述SQL with(unlock)与with(readpast)
    SQLServer 查询最近一天,三天,一周,一月,一季度数据的方法
    C# DevExpress GridControl使用方法
    SQL一列的合并连起来
    DevExpress Report打印边距越界问题
    C# 快速高效率复制对象另一种方式 表达式树
    SQL传数组到存储过程中
    LogNet4学习笔记
    使用Squid部署代理缓存服务(标准正向、透明正反向代理)
    使用Postfix与Dovecot收发电子邮件(物理机虚拟机之间)
  • 原文地址:https://www.cnblogs.com/hannover/p/2312531.html
Copyright © 2011-2022 走看看