如何检索Lotus Notes附件? [英] How to retrieve Lotus Notes attachments?

查看:104
本文介绍了如何检索Lotus Notes附件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Lotus Notes数据库(使用Designer 7.0)导出所有文档及其附件.我可以获取文档数据并可以获取附件,但前提是我必须对名称进行硬编码.我发现在LotusScript中,这两种方法无法以编程方式获取文件名,如下面的两个代码块所示.在第一个文档中,doc.GetFirstItem("Body")返回Nothing,在第二个文档中,在Forall行执行期间存在类型不匹配.任何有关如何提取附件的帮助将不胜感激!我不确定附件是存储为附件"还是OLE,但我怀疑是附件,因为它们主要是PDF.

I’m trying to export all of the documents and their attachments from a Lotus Notes database (with Designer 7.0). I can get the document data and can get an attachment, but only if I hard code the name. The two methods, in LotusScript, I’ve found for getting the filename programmatically aren’t working, as shown in the lower two code blocks. In the first, doc.GetFirstItem( "Body" ) returns Nothing, and in the second, there’s a Type Mismatch during execution on the Forall line. Any help on how to extract the attachments would be greatly appreciated! I’m not sure whether the attachments are stored as "attachments" or OLE, but I suspect as attachments, since they’re primarily PDFs.

Sub Click(Source As Button)  
Dim session As New NotesSession
Dim db As NotesDatabase
Dim query As String
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim fileCount As Integer
Dim attachment As NotesEmbeddedObject 
Dim fileName As String

Set db = session.CurrentDatabase
' get a document that has an attachment
Set collection = db.FTSearch( "06/25/2013", 10 )

fileNum% = Freefile()
fileName$ = "c:\kcw\lotusexport.txt"
Open fileName$ For Output As fileNum%
Write #fileNum%, "docs found", collection.Count

Set doc = collection.GetFirstDocument
' write out document properties
Forall x In doc.Items
    Write #fileNum%, x.Name, " = ",  x.Text
End Forall
'extract document (using hardcoded name)
Set attachment = doc.GetAttachment("OCSE-FRONT_SCANTODESKTOP_06262013-104822.pdf")
Call attachment.ExtractFile _
( "c:\kcw\attachment" )

'Try to get attachment through "Body", but rtitem is Nothing
Set rtitem = doc.GetFirstItem( "Body" )
Write #fileNum%, "rtitem is Nothing", rtitem Is Nothing
fileCount = 0
If Not rtitem Is Nothing Then
    If ( rtitem.Type = RICHTEXT ) Then
        Write #fileNum%, "rtitem is RICHTEXT"
        Forall o In rtitem.EmbeddedObjects
            Write #fileNum%, "has Embedded Objects"
            fileCount = fileCount + 1
            Write #fileNum%,"rtitem num", fileCount
            Call o.ExtractFile _
            ( "c:\kcw\newfile" & Cstr(fileCount) )
        End Forall
    End If
End If

'Fails with "Type mismatch" at Forall loop
If doc.HasEmbedded Then
    Write #fileNum%, "doc has embedded"     
    Forall objects In doc.EmbeddedObjects
        Write #fileNum%, "in for loop"
        Write #fileNum%, "filename= ", object.Source
    End Forall
End If

Close fileNum%
End Sub

推荐答案

,它将为您提供文档中所有附件的列表

that will give you list of all attachments in document

objects =  Evaluate("@AttachmentNames", doc)

这篇关于如何检索Lotus Notes附件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆