Lotusscript跳过数组中的元素?

时间:2012-09-28 06:48:29

标签: lotusscript

我有3个(或更多)部门。每个部门都有电子邮件收件人。例如:

部门A:约翰,玛丽。部门B:约翰,克里斯。部门C:约翰。

字段(文本列表)以部门形式称为EmailRecipient。目前我已设法向每个部门的每个收件人发送电子邮件。但我只需要向John发送一次电子邮件,因为电子邮件的内容是相同的。我目前在我的测试代理中所做的工作如下:

Dim view As NotesView, doc As NotesDocument
Set view=db.Getview("Department")
Set doc=view.Getfirstdocument()
Do While Not doc Is Nothing
    ForAll x In doc.EmailRecipient
        Set doc=db.Createdocument()
        doc.form="Memo"
        doc.subject="test"
        Call doc.Send(True, x)
    End ForAll
Loop

如果我已经向他发送了电子邮件,我如何在下一个部门的EmailRecipient数组中跳过John?

1 个答案:

答案 0 :(得分:2)

使用列表。如果您不了解LotusScript中的List数据类型,请在Domino Designer帮助数据库中查找“使用列表”。

在循环之外,您将创建一个列表:

dim alreadySent List as String

在你的forall中,你将每个名字添加到列表中:

alreadySent(x) = departmentName

最后,您将调用doc.Send调用列表中的if语句:

if isElement(alreadySent(x)) = True then
   ' print "Skipping " + x + " because the message was already to this recipient sent for department " + alreadySent(x) 
   Call doc.send(True,x)
end if

请注意,我在这里即兴创作。我假设您的Dept表单有一个名称字段。我知道你实际上没有读过它,但是你很容易添加。你真的不必这样做,因为你可以很容易地声明'alreadySent List as Boolean'并且已经指定alreadySent(x)= True,但是通过使用String List并为每个收件人分配departmentName,你可以跟踪哪个部门你已经看过这个用户了。我收录了注释掉的print语句,以说明这可能有用。