任何时候对表格进行更改,都会发送一封自动电子邮件

Anytime changes are made on a form, an automatic email will be sent

您好,如何将其设置为自动电子邮件通知?现在它是通过单击按钮的手册。

手动按钮代码:

Sub Click(Source As Button) 
    Dim db As NotesDatabase 
    Dim doc As NotesDocument 
    ' get the database 
    Set db = New NotesDatabase( "", "LotusScript.nsf" ) 
    ' create a new document in the database 
    Set doc = New NotesDocument( db ) 
    ' set the new document's form so it'll be readable as a mail memo 
    doc.Form = "Memo" 
    ' set the new document's subject 
    doc.Subject = "Change Notification" 
    ' set the new document's body 
    doc.Body = "This Email is to notify you that changes has been made." 
    ' mail the new document 
    Call doc.Send( False, "Lekhwair Alatan" ) 
End Sub

要自动执行此操作,您可以使用完全相同的代码。

您只需将其放入表单"PostSave"- 事件

我只是不明白,为什么您需要打开特定的数据库才能执行此操作。我会为此使用 CurrentDatabase。

此外:我会使用 NotesRichtextitem 并向其添加 Doclink,以便用户可以通过单击 link 在邮件中:

Sub PostSave( Source as NotesUIDocument )
    Dim ses as New NotesSession
    Dim db As NotesDatabase 
    Dim doc As NotesDocument 
    Dim body as NotesRichtextItem
    ' get the database 
    Set db = ses.CurrentDatabase
    ' create a new document in the database 
    Set doc = New NotesDocument( db ) 
    ' set the new document's form so it'll be readable as a mail memo 
    doc.Form = "Memo" 
    ' set the new document's subject 
    doc.Subject = "Change Notification" 
    ' set the new document's body 
    Set body = New NotesRichtextitem( doc, "Body" )
    Call body.AppendText( "This Email is to notify you that changes has been made." )
    Call body.AddNewLine(1)
    Call body.AppendText( "Click here to open document --> " )
    Call body.AppendDocLink( Source.document, "Click me" )
    ' mail the new document 
    Call doc.Send( False, "Lekhwair Alatan" ) 
End Sub

注意:您不能在按钮中使用此代码,因为 "Source" 是按钮而不是当前文档。您还需要 1 行代码和一处更改:

Dim ws as New NotesUIWorkspace ' this line at the very top
....
Call body.AppendDocLink( ws.CurrentDocument.document, "Click me" ) 'this instead of Source.document