通过lotusscript更新文件中的签名

时间:2014-11-05 08:52:28

标签: lotusscript

我是lotusscript中的新手,我希望每次可以访问该文件时都从html文件更新签名富文本。因此,当我自动更改html文件时,它将更改签名。 我在代码下面尝试了onload表单事件,但没有运气。我使用Domino Designer 8.5

Sub Onload(Source As Notesuidocument)
'*********************************************************
'Refresh Signature from html file and if file is aviable
'*********************************************************
If source.IsNewDoc Then 
    Dim session As New NotesSession

    'Open users mail database
    Set dbMail = session.CurrentDatabase

    If Not dbMail.IsOpen Then
        Call dbMail.OpenMail
    End If

    Set docProfile = dbMail.GetProfileDocument("CalendarProfile")

    'Check if file exist
    If Not Dir$( "mypath\fileName.html", 0 ) = "" Then

        Set workspace = CreateObject("Notes.NotesUIWorkspace")
        Call workspace.EditDocument(True, Source)
        Set curDoc =  source.Document

        Dim tmpRich As New NotesRichTextItem( curDoc , "Signature_Rich" )

        Call source.GotoField("Signature_Rich")
        Call source.Import("HTML File", "mypath\fileName.html") '// seems that Import does not exist.
        Set newRich= curDoc.GetFirstItem("Signature_Rich")

        Dim richTextItem As New NotesRichTextItem( docProfile , "Signature_Rich" )
        Call richTextItem.AppendRTItem (newRich)
        'Call richTextItem.AppendText ("test")
        Call docProfile.Save(True, False) 
    End If
End If End Sub

1 个答案:

答案 0 :(得分:0)

由于假设HTML文件是签名的权威来源,为什么即使两者都导入它?只需配置日历配置文件即可使用HTML文件。如果您需要以编程方式执行此操作以阻止用户更改签名,则可以使用此代码确保正确配置日历配置文件。您可以将它放在Message表单的QueryOpen中。你可能也想要回复和回复历史&附件表格也是如此。

If source.IsNewDoc Then
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Set db = s.CurrentDatabase

    Dim profile As NotesDocument
    Set profile = db.GetProfileDocument("CalendarProfile")    

    Call profile.ReplaceItemValue("SignatureOption", "2")
    Call profile.ReplaceItemValue("Signature_2", "mypath\fileName.html")
    Call profile.Save(True, False)
End If

有更好的工具来管理签名,我强烈建议使用这些工具而不是这种方法。