DOMINO 附件拆分

时间:2019-03-18
本文章向大家介绍DOMINO 附件拆分,主要包括DOMINO 附件拆分使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

domino 中关于附件的部分确实很伤,noteitem对象中貌似没有关于java文件流的处理,只好采用折中的方法,先拆分,后上传,估计IO够呛。

Sub Initialize
    
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim dc As NotesDocumentCollection
    Dim rtitem As NotesRichTextItem
    Dim object As NotesEmbeddedObject
    Dim fileCount As Integer    
    Const MAX = 100000
    fileCount = 0
    
    Set db = session.Currentdatabase
    Set dc= db.Unprocesseddocuments()
    Set doc = dc.Getfirstdocument()
 

'''''''''''''''''''''''''''''

If Not attdoc Is Nothing Then 
                    Dim rtitem As NotesRichTextItem
                    Dim obj As NotesEmbeddedObject
                    Dim fileCount As Integer
                    filecount=0
                    tt=Evaluate("@AttachmentNames",attdoc)
                    For j=0 To UBound(tt)
                        Set obj=attdoc.Getattachment(tt(j))
                         If Not obj Is Nothing Then 
                             obj.Extractfile("d:\fw\"+obj.Name)
                         End If
                    Next
                End If

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


   %REM
       步骤一:    先将选中的文档的附件进行拆分,放入指定位置
   %END REM
    Set rtitem = doc.Getfirstitem("attachement")
    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:\newfile" & CStr(fileCount) )
                Call doc.Save( True, True )
            End If
        End ForAll
    End If
    
    %REM
        步骤二:新建文档,并上传附件
    %END REM
    Set doc = New NotesDocument( db )
    Set rtitem = New NotesRichTextItem(doc, "attachement" )
    While(fileCount)
        Set object = rtitem.EmbedObject(EMBED_OBJECT, "", "c:\newfile" & CStr(fileCount))
        fileCount = fileCount - 1
    Wend
    doc.Form = "Attachement"
    doc.Subject ="Here's Jim's document, as an embedded object"
    Call doc.Save( True, True )

end sub