[英]How can I delete a mail database in HCL Domino over Lotus Script?
我想通過筆記代理刪除郵件數據庫。 有時郵件數據庫有一個副本。
刪除郵件文件本身以及所有其他副本(如果存在)的最佳方法是什么? 我下面的代碼看起來像這樣,但它不會刪除副本中的郵件文件。
Dim mailfile As String
mailfile = "mail\doe.nsf"
Dim db As New NotesDatabase("", mailfile)
If db.IsOpen Then
'Mark to delete it later
Call db.MarkForDelete()
Else
'Delete now
Call db.Remove
End If
您可以使用內置的 function 通過NotesAdministrationProcess執行此操作:
Sub Initialize
Dim session As New NotesSession
Dim adminp As NotesAdministrationProcess
Set adminp = _
session.CreateAdministrationProcess("Software_Server")
noteid$ = adminp.DeleteReplicas("Software_Server", "Guys1")
'- in case you want to open the generated adminp request
If noteid$ <> "" Then
Dim db As New NotesDatabase("Software_Server", "admin4")
Dim ws As New NotesUIWorkspace
Call ws.EditDocument(False, db.GetDocumentByID(noteid$))
End If
End Sub
如果您不想等待(因為它需要時間:將 admin4.nsf 復制到所有服務器,在那里執行管理進程,復制回來......),如果您知道副本所在的服務器,您可以自己執行此操作提前:
Dim mailfile As String
mailfile = "mail\doe.nsf"
Dim otherServers(2) as String
Dim replicaID as String
Dim db as NotesDatabase
otherServers(0) = "FirstServerName/Certifier"
otherServers(1) = "SecondServerName/Certifier"
otherServers(2) = "ThirdServerName/Certifier"
Set db = New NotesDatabase("PrimaryServer/Certifier", mailfile)
If db.IsOpen Then
replicaID = db.ReplicaID
On Error Goto ErrorRemove
'Delete now
Call db.Remove
On Error Goto ErrorHandler
Forall serverName in otherServers
Set db = New NotesDatabase("", "")
Call db.OpenByReplicaID( serverName, replicaID )
If db.IsOpen Then
On Error Goto ErrorRemove
'Delete now
Call db.Remove
On Error Goto ErrorHandler
End If
End Forall
End If
EndOfRoutine:
Exit Sub
ErrorRemove:
Call db.MarkForDelete()
Resume Next
ErrorHandler:
'- do usual error handling here
備注:您對“db.IsOpen”的檢查根本沒有幫助。 如果數據庫當前在某處打開,則“IsOpen”不會返回。 它返回,如果您的腳本能夠在那個時刻打開數據庫......我添加了一個錯誤處理程序來考慮這一點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.