繁体   English   中英

如何通过 Lotus Script 删除 HCL Domino 中的邮件数据库?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM