Lotus notes 如何从通讯簿中检查发送至短id是否有效
上述调用doc.Send(False,False)不会发送到错误处理程序,尽管doc.SendTo有错误的短id,因为它有CC和BCC短id是正确的。我的要求是它应该去错误处理程序,或者它不应该发送邮件时,发送到是错误的。我怎样才能从通讯簿中查看“发送到”Lotus notes 如何从通讯簿中检查发送至短id是否有效,lotus-notes,lotusscript,Lotus Notes,Lotusscript,上述调用doc.Send(False,False)不会发送到错误处理程序,尽管doc.SendTo有错误的短id,因为它有CC和BCC短id是正确的。我的要求是它应该去错误处理程序,或者它不应该发送邮件时,发送到是错误的。我怎样才能从通讯簿中查看“发送到” doc.Principal = confdoc.mDefaultPrincipal(0) doc.SendTo = curdoc.empShortID(0) Call doc.Send(False, False)
doc.Principal = confdoc.mDefaultPrincipal(0)
doc.SendTo = curdoc.empShortID(0)
Call doc.Send(False, False)
不幸的是,只要至少有一个地址是正确的,这就不会产生错误。 您必须手动检查所有地址才能获得错误。最好的方法是遍历所有地址,并在domino目录中的($Users)-View中查找它们。 这可能是这样的:
errorhandler:
Print "Error in function TriggerMail -- " & Cstr(Error) & " -- occured at line - " & Cstr(Erl())
MsgBox Err
If Err = 4294 Then
curdoc.Flag = "Invalid 'To' Shortname"
curdoc.defaulterSLACount = CInt(defaultCount)
Call curdoc.Save(False, True)
Exit function
End If
这段代码没有经过测试,但是想法应该很清楚,即使在这个示例中有输入错误(此时没有打开设计器进行检查)。如果您确定服务器只配置了一个Domino目录,那么转到$Users视图是可以的。假设您处理的是Notes 8或更高版本,NotesDirectory类的LookupNames方法更可取。这是正确的,也是一个很好的观点。但是:LookupNames还会在客户端的local names.nsf中搜索。。。在某些情况下,这可能会适得其反
Dim varRecipients as Variant
varRecipients = doc.SendTo
varRecipients = ArrayUnique( ArrayAppend( varRecipients, doc.CopyTo ) )
varRecipients = ArrayUnique( ArrayAppend( varRecipients, doc.BlindCopyTo ) )
Dim dbNab as NotesDatabase
Dim viwLkp as NotesView
Dim docPerson as NotesDocument
Set dbNab = New NotesDatabase( db.Server, "names.nsf" )
Set viwLkp = dbNab.GetView( "($Users)" )
Forall strRecipient in varRecipients
'- this check is optional. Addresses with an @ never create an err 4294
'- If your function never sends mails outside of the domain, you can omit it.
If instr( strRecipient, "@" ) = 0 then
Set docPerson = viwLkp.GetDocumentByKey( strRecipient, True )
If docPerson is Nothing then
'- flag your document, do whatever you want,
'- as this recipient does not exist
End If
End If
End Forall