2014-11-05 25 views
0

我是lotusscript中的新手,每次我可以訪問該文件時,我都想從html文件更新簽名富文本。所以當我將自動更改html文件時,它將改變簽名。 我已經嘗試在代碼下面的onload窗體事件,但不是運氣。我用Domino Designer中8.5從lotusscript更新文件簽名

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 
+0

你把這段代碼放在哪裏? 「Onload」 - 哪種形式的事件? Onload事件通常發生在早期,並且使用「Call workspace.EditDocument(True,Source)」更改當前文檔窗口(並且我不確定,如果此工作在onLoad中)...並且:此代碼將NotesUIDocument和NotesDocument並永遠不能正常運行。 – 2014-11-05 09:51:31

+0

我在消息表單中運行它。我的NotesDocument混合NotesUIDocument,因爲我無法找到任何解決方案從文件 – santipianis 2014-11-05 10:15:49

+0

更新豐富的簽名我已經嘗試使用CalendarProfile表單簽名NotesUIDocument但關閉窗體後,不保留任何變化 – santipianis 2014-11-05 10:24:57

回答

0

由於假設是HTML文件是簽名的權威來源,爲什麼還要與兩個進口呢?只需配置日曆配置文件即可使用HTML文件。如果您需要以編程方式執行此操作以防止用戶更改簽名,則可以使用此代碼確保日曆配置文件配置正確。你可以把它放在消息表單的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 

有更好的工具來管理簽名,我強烈推薦使用這些方法而不是這種方法。

+0

謝謝你的回覆。是不錯的解決方案,但問題是HTML文件位於本地網絡服務器上,所以有時候我無法訪問文件。使用您的配置,當您無法訪問文件時,您將收到錯誤信息和郵件而無需簽名。 Actualy有可能從nfs服務器獲取文件? – santipianis 2014-11-07 08:45:31