lotus-notes - 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 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
结束子
解决方案
您需要将逻辑包装在这样的循环中。它将循环您收件箱中的所有文档,如果主题匹配,它将执行您想要放入“对文档进行操作”区域的任何内容。
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
您将不再需要coll
推荐阅读
- json - 使用 Google Apps 脚本从 JSON 对象创建 Google Sheet
- postgresql - heimir-sverrisson 为 postgres 构建 jdbc2_fdw 时出现几个构建错误
- angular - Primeng 编辑器添加撤消和重做按钮
- postgresql - 如何抑制来自控制台的警告
- javascript - TypeError:在 14 处缺少参数名称
- xslt - 使用 xslt 3.0 基于 Element 属性合并(左连接)2 个 XML 文件
- python - 如何在二维列表的一行中找到最大值及其索引?
- r - 为什么我的服务站点没有呈现此错误?
- swift - 如何创建抛物线形状的 SKPhysicsBody?
- swift - 滑动以仅删除 SwiftUI 列表中的选定行?