Hi how do I make this be a automatic email notification? Right now its a manual via clicking a button.
Manual Button Code:
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
To do this automatically you can use exactly the same code.
You just have to put it in the "PostSave"- Event of your form.
I just don't get, why you need to open a specific database to do this. I would use CurrentDatabase for that.
In addition: I would use a NotesRichtextitem and add a Doclink to it, so that the user can instantly open the document by clicking the link in the mail:
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
TAKE CARE: You cannot use this code in your Button, as there "Source" is the button and not the current document. You'd need 1 more line of code and one change:
Dim ws as New NotesUIWorkspace ' this line at the very top
....
Call body.AppendDocLink( ws.CurrentDocument.document, "Click me" ) 'this instead of Source.document