例: LookupNames method

  1. 次のコードは、$Users ビュー内の、「Smith」が含まれているすべてのエントリを検索し、個人の短縮名とインターネットアドレスのディレクトリナビゲータを作成します。
  Dim s As New notessession
  Dim myname As String
  myname = "Smith"  
  
  Dim myitems() As String
  Redim myitems(1 To 2)  
  
  myitems(1) =  "ShortName"
  myitems(2) =  "InternetAddress"
  
  Set mydir = s.GetDirectory("myserver")
  
  Set mynav = mydir.LookupNames("$Users", myname, myitems, True)
  
  While mynav.NameLocated  
    While mynav.MatchLocated    
      v = mynav.getFirstItemValue
      mynav.FindNextMatch  ' sets MatchLocated T/F
    Wend
'    resume name loop
    mynav.FindNextName  ' sets NameLocated T/F
  Wend
  Msgbox "complete"  

  1. 2. このボタンにより、ローカルディレクトリ内の個人アドレス帳の [連絡先] ビューにアクセスして、名前に一致する各文書の [FullName] アイテムと [InternetAddress] アイテムの値を返します。
Dim session As NotesSession
Dim directory As NotesDirectory
Sub Initialize
	Set session = New NotesSession
	Set directory = session.GetDirectory("")
End Sub

Sub Click(Source As Button)
	Dim nav As NotesDirectoryNavigator
	Dim msg As String
	Dim value As Variant
	Dim names As String
	Dim items( 1 To 2) As String
	items(1) = "FullName"
	items(2) = "InternetAddress"
	names = Inputbox$("Enter last name")
	If names = "" Then Exit Sub
	Set nav = directory.LookupNames("My Contacts", names, items, True)
	If nav.CurrentMatches > 0 Then
		Do
			msg = msg & Cstr(nav.CurrentMatch) & | |
			value = nav.GetFirstItemValue
			msg = msg & Cstr(value(0)) & | |
			value = nav.GetNextItemValue
			msg = msg & Cstr(value(0)) & |
|
		Loop While nav.FindNextMatch
	End If
	Msgbox msg,, "My Contacts"
End Sub

3. このボタンにより、サーバー上の Domino ディレクトリの [ユーザー] ビューにアクセスして、名前に一致する各文書の [FullName] アイテムと [InternetAddress] アイテムの値を返します。

Dim session As NotesSession
Dim directory As NotesDirectory
Sub Initialize
	Set session = New NotesSession
	Set directory = session.GetDirectory("myserver/Acme")
End Sub

Sub Click(Source As Button)
	Dim nav As NotesDirectoryNavigator
	Dim msg As String
	Dim value As Variant
	Dim names As String
	Dim items( 1 To 2) As String
	items(1) = "FullName"
	items(2) = "InternetAddress"
	names = Inputbox$("Enter last name")
	If names = "" Then Exit Sub
	On Error Goto errh ' Bad server name causes exception
	Set nav = directory.LookupNames("People", names, items, True)
	On Error Goto 0
	If nav.CurrentMatches > 0 Then
		Do
			msg = msg & Cstr(nav.CurrentMatch) & | |
			value = nav.GetFirstItemValue
			msg = msg & Cstr(value(0)) & | |
			value = nav.GetNextItemValue
			msg = msg & Cstr(value(0)) & |
|
		Loop While nav.FindNextMatch
	End If
	Msgbox msg,, "People"
	Exit Sub
errh:
	Msgbox Error(),, Err()
	Exit Sub
End Sub