Lotus notes LotusScript-按主题查找文档

Lotus notes LotusScript-按主题查找文档,lotus-notes,lotus-domino,lotusscript,Lotus Notes,Lotus Domino,Lotusscript,您好,我写了这段代码(从我在网上找到的站点复制)来在我的lotus notes收件箱视图中查找电子邮件并保存附件。 我不能做的是找到我需要的主题的文档。集合未填充。我错在哪里?谢谢 Sub Initialize Dim sess As New NotesSession Dim db As NotesDatabase Dim coll As NotesDocumentCollection Dim doc As NotesDocument Dim rtitem As Variant Dim file

您好,我写了这段代码(从我在网上找到的站点复制)来在我的lotus notes收件箱视图中查找电子邮件并保存附件。 我不能做的是找到我需要的主题的文档。集合未填充。我错在哪里?谢谢

Sub Initialize
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtitem As Variant
Dim filename As Variant

Const DIR_NOT_FOUND = 76
Dim i As Integer
Dim strname As String
Dim view As NotesView
Dim myArray (1 To 2) As String
myArray (1) = "DataToBeSaved"
myArray (2) = "DataToBeSaved"

Set db = sess.currentdatabase
Set view = db.GetView("($Inbox)" )

Set coll = view.GetAllDocumentsByKey(myArray,False)
Set doc = coll.GetFirstDocument()

While Not doc Is Nothing
    Set rtitem = doc.GetFirstItem("Body")
    If Not rtitem Is Nothing Then
        If ( rtitem.Type = RICHTEXT ) Then
            If Isempty(rtitem.EmbeddedObjects) = False Then
                Forall o In rtitem.EmbeddedObjects
                    If ( o.Type = EMBED_ATTACHMENT ) Then
                        filename = Evaluate("@AttachmentNames", doc)
                        'For i = 0 To Ubound(filename)
                        If (filename(i)="query nas.txt") Then
                            strname = Replace(filename(i), "/", "-")
                            On Error DIR_NOT_FOUND Resume Next
                            Call o.ExtractFile( "\\rflenas1.rfle.roto-frank.com\RFIB\LOTUSPROVA\" & strname )
                        End If                          
                        'Next
                        doc.fieldname = ""
                        Call doc.Save( True, True )
                    End If
                End Forall
            End If
        End If
    End If
    Set doc = coll.getnextdocument(doc)
Wend

End Sub

您需要像这样将逻辑封装在一个循环中。它将环绕收件箱中的所有文档,如果子EJCT匹配,它将执行您想放在“对文档做点什么”区域中的任何操作


您将不再需要
coll

您需要为doc.Subject(0)=“您要查找的主题”添加检查。因此我不必使用GetAllDocumentsByKey?那么,关键是什么呢?在你的
之后,doc.Subject在我的lotus中不存在,而doc不是空的
添加
如果doc.Subject(0)=“Subject TO MATCH”,那么在
设置doc=coll.getnextdocument(doc)
之前放置
end if
。说明:
doc.subject(0)
表示获取doctanks中subject字段的字符串值,有效:)我使用了一个集合,因为我只在未读文档中搜索。如果我搜索整个视图或数据库,速度会非常慢。您仍然可以循环遍历集合,但必须测试doc.Subject()。收件箱文件夹中没有“键”,因为它不是排序视图。GetAllDocumentByKey搜索第一个排序列。顺便说一句,有一个未处理的文档集合(在documentiaton中查找NotesDatabase类),但是(据我所知)没有一个未读文档的集合。
set doc = view.getfirstdocument
while not doc is nothing
    if doc.subject(0) = "THE SUBJECT I WANT TO FIND" then
    'Do something with the doc
end if
    set doc = view.getnextdocument(doc)
Wend