这是琼斯建议的快速实施:
Function getMailFileUser(mailserver As String, mailfile As String) As String
On Error Goto errorthrower
Dim session As New notessession
Dim dd As NotesDatabase
Forall candidate_dd In session.AddressBooks
If candidate_dd.Server<>"" And candidate_dd.IsPublicAddressBook Then
Set dd = candidate_dd
Exit Forall
End If
End Forall
If dd Is Nothing Then Error 1978,"Failed to find Domino Directory"
If Not dd.IsOpen Then Call dd.Open("","")
Dim userdocs As NotesDocumentCollection
Set userdocs = dd.Search({form="Person" & }& _
{@name([CANONICALIZE];MailServer)=@name([CANONICALIZE];"} & mailserver & {") & } &_
{MailFile="} & mailfile & {"},Nothing,1)
Dim userdoc As NotesDocument
Set userdoc = userdocs.GetFirstDocument
If Not userdoc Is Nothing Then
getMailFileUser = userdoc.FullName(0)
Else
getMailFileUser=""
End If
Exit Function
ErrorThrower:
Error Err, Error & Chr(13) + "Module: " & Cstr( Getthreadinfo(1) ) & ", Line: " & Cstr( Erl )
End Function
提醒几句:
CANONICALIZE
从当前 ID,而不是 domino 目录中选择它的值 - 输入mailserver
必须是缩写或规范化的形式才能工作。
- 该
MailFile
字段可能包含也可能不包含.nsf
扩展名。
- 我认为文件名在 Windows 上不区分大小写,但它可能在其他平台上。
如果您需要经常进行这些查找,那么计算查找表或 Domino 目录中的视图可能是最有效的解决方案。