如何检查您的Send TO短信ID是否在地址簿中有效

问题描述 投票:1回答:1
    doc.Principal = confdoc.mDefaultPrincipal(0)
    doc.SendTo = curdoc.empShortID(0)

    Call doc.Send(False, False)

上面调用doc.Send(False,False)不会出现错误处理程序虽然doc.SendTo有错误的短ID,因为它有CC和BCC短ID是正确的。我的要求是它应该转到错误处理程序或它不应该发送邮件时发送错误。我如何检查发送到地址簿。

 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
lotus-notes lotusscript
1个回答
0
投票

不幸的是,只要至少有一个地址可以,这就不会产生错误。您必须手动检查所有地址以获取错误。最好的方法是遍历所有地址,然后查看($ Users) - 在domino目录中查看。这可能如下所示:

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

这段代码没有经过测试,但是这个想法应该是清楚的,即使这个例子中有拼写错误(目前没有设计师打开来检查)。

© www.soinside.com 2019 - 2024. All rights reserved.