Lotus notes 任何时候对表单进行更改,都会自动发送电子邮件

Lotus notes 任何时候对表单进行更改,都会自动发送电子邮件,lotus-notes,lotus-domino,lotusscript,lotus,lotus-formula,Lotus Notes,Lotus Domino,Lotusscript,Lotus,Lotus Formula,嗨,我如何使这成为一个自动电子邮件通知?现在它是一个手动通过点击一个按钮 手动按钮代码: 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 d

嗨,我如何使这成为一个自动电子邮件通知?现在它是一个手动通过点击一个按钮

手动按钮代码:

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,以便用户可以通过单击邮件中的链接立即打开文档:

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
注意:您不能在按钮中使用此代码,因为“源”是按钮,而不是当前文档。您还需要一行代码和一个更改:

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

嗨,托尔斯滕,谢谢你的回答。我能知道这些线是干什么用的吗?Call body.AppendText(“单击此处打开文档-->”)Call body.AppendDocLink(Source.document,“单击我”)如果没有按钮,我如何进行此操作。例如,我打开一个文档,编辑,然后单击保存。将自动发送一封电子邮件。您阅读了我的答案吗
只需将其放入表单的“PostSave”事件中
。如果你想知道,这些行是用来做什么的:是吗?:
此外,我会使用NotesRichtextitem并向其中添加Doclink,这样用户可以通过单击
立即打开文档,谢谢!现在一切都好了。如果你不生气,你有最好的办法。如何向多个收件人发送邮件?有没有办法替换发送者的名字?(LAlatan@qwerty.com)提示:发送给多个收件人和替换发件人姓名是新问题。StackOverflow强烈反对使用评论线程来提出新问题。如果你想得到这些问题的答案,你应该提出新的问题——但首先,你应该进行搜索。我非常肯定,这两个问题以前都已经被问过并得到了回答。