【问题标题】:How can I delete a mail database in HCL Domino over Lotus Script?如何通过 Lotus Script 删除 HCL Domino 中的邮件数据库?
【发布时间】:2022-09-24 16:29:45
【问题描述】:

我想通过笔记代理删除邮件数据库。有时邮件数据库有一个副本。

删除邮件文件本身以及所有其他副本(如果存在)的最佳方法是什么? 我下面的代码看起来像这样,但它不会删除副本中的邮件文件。

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

    标签: lotus-notes lotus-domino lotusscript lotus hcl


    【解决方案1】:

    您可以通过使用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”不会返回。它返回,如果您的脚本能够在那个时刻打开数据库......我添加了一个错误处理程序来考虑这一点。

    【讨论】:

    • Todoe 非常感谢你。在您的第一个建议中,Software_Server 是什么?这是邮件服务器,它正在运行吗?其次,是否可以删除位于与代理/莲花脚本运行不同的多米诺服务器上的邮件数据库?
    • Software_Server 只是一个示例服务器名称。你会用你自己的代替。它应该是配置为邮件数据库管理服务器的服务器。您可以使用 NotesDatabase.ACL,AdministrationServer 找到管理服务器。
    • 嗨@RichardSchwartz 非常感谢你。它与 NotesAdministrationProcess 一起工作。只有一个问题/开放点:在 admin4.nsf 中,它要求我手动批准。有没有机会跳过它并直接删除它?
    • 您是否阅读了链接的文档?尝试使用“ApproveReplicaDeletion”...
    猜你喜欢
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多