zgr168
10-02-06, 03:53 PM
你想通过编程的方法在个人通讯录中更新或删除某一服务器的连接文档。是否有办法实现?
可以使用 LotusScript 实现这一功能。下面的例子介绍了如何使用 NotesSession 类的 AddressBooks 属性获得当前通讯录的句柄,并利用这个信息循环访问所有的个人通讯录。
由于并不是所有的用户都用 names.nsf,使用 AddressBooks 属性得到个人通讯录的句柄是最好的办法。接下来是获得数据库中“Connections”视图的句柄并循环访问视图中所有文档,找到与目标服务器名称相同的文档。
你可以根据目标服务器名称,IP地址来更改例子中的代码,以便在不同环境运行。
可以在新建的便签中创建一个按钮,把这段代码写在按钮的“Click”事件中,通过邮件发送给最终用户。
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim nextdoc as NotesDocument
Dim destLocation As Variant
Dim allnabs as Variant
allnabs=session.addressbooks
Forall books In allnabs
'If The NAB Is Private, Than It Should Be Your Personal NAB
If books.isprivateaddressbook Then
'Verify if The NAB is Open, If Not, Open it
If Not(Books.isopen) Then
Call Books.open("",books.filename)
End If
Set view = db.GetView("Connections")
Set doc = view.GetFirstDocument
While Not doc Is Nothing
destServer = doc.GetItemValue("Destination")
Set nextdoc=view.GetNextDocument(doc)
'THE BELOW LINE MUST BE MODIFIED TO SPECIFY THE RELATIVE SERVER NAME:
If destServer(0) = "CN=serverName/O=domain" Then
'If you want to remove the document include this line:
Call doc.Remove(True)
'If you want to update the Destination field include the below instead:
Call doc.replaceitemvalue ("Destination","CN=servername/O=domain")
'If you want to update the Destination Server Address entry include the below:
Call doc.replaceitemvalue ("OptionalNetworkAddress","<IP address>")
'Include the line below if you've included either of the ReplaceItemValue calls:
Call doc.save (True,True)
End If
Set doc=nextdoc
Wend
End If
End Forall
可以使用 LotusScript 实现这一功能。下面的例子介绍了如何使用 NotesSession 类的 AddressBooks 属性获得当前通讯录的句柄,并利用这个信息循环访问所有的个人通讯录。
由于并不是所有的用户都用 names.nsf,使用 AddressBooks 属性得到个人通讯录的句柄是最好的办法。接下来是获得数据库中“Connections”视图的句柄并循环访问视图中所有文档,找到与目标服务器名称相同的文档。
你可以根据目标服务器名称,IP地址来更改例子中的代码,以便在不同环境运行。
可以在新建的便签中创建一个按钮,把这段代码写在按钮的“Click”事件中,通过邮件发送给最终用户。
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim nextdoc as NotesDocument
Dim destLocation As Variant
Dim allnabs as Variant
allnabs=session.addressbooks
Forall books In allnabs
'If The NAB Is Private, Than It Should Be Your Personal NAB
If books.isprivateaddressbook Then
'Verify if The NAB is Open, If Not, Open it
If Not(Books.isopen) Then
Call Books.open("",books.filename)
End If
Set view = db.GetView("Connections")
Set doc = view.GetFirstDocument
While Not doc Is Nothing
destServer = doc.GetItemValue("Destination")
Set nextdoc=view.GetNextDocument(doc)
'THE BELOW LINE MUST BE MODIFIED TO SPECIFY THE RELATIVE SERVER NAME:
If destServer(0) = "CN=serverName/O=domain" Then
'If you want to remove the document include this line:
Call doc.Remove(True)
'If you want to update the Destination field include the below instead:
Call doc.replaceitemvalue ("Destination","CN=servername/O=domain")
'If you want to update the Destination Server Address entry include the below:
Call doc.replaceitemvalue ("OptionalNetworkAddress","<IP address>")
'Include the line below if you've included either of the ReplaceItemValue calls:
Call doc.save (True,True)
End If
Set doc=nextdoc
Wend
End If
End Forall