例如:下例中的LotusScript代码可以发送一封欢迎 邮件,主题为“Welcome某某用户”,正文部分为“Hello 某某用户,Welcome to the company”。
下面样例中的代码使用简要表文档和域值来检查并标记该用户是否已经接受过欢迎邮件。注意CommonUserName属性(属于NotesSession 类)仅用于欢迎词中,而当这封邮件被Send方法(属于NotesDocument类)调用的时候,会用到更为详细的UserName属性。
Sub Postopen(Source As Notesuidatabase)
Dim s1 As New notessession
Dim db1 As notesdatabase
Dim memo1 As notesdocument
Dim pdoc1 As NotesDocument
Set db1=s1.CurrentDatabase
Set pdoc1=db1.getprofiledocument("SentHello")
If Not pdoc1.HasItem("SentHello") Then
Set memo1=db1.createdocument
memo1.subject="Welcome " & s1.CommonUserName
memo1.form="Memo"
Dim rtf1 As New notesrichtextitem(memo1, "Body")
Call rtf1.appendText("Hello " & s1.CommonUserName & ",")
Call rtf1.addnewline(2)
Call rtf1.appendtext("Welcome to the company.")
Call memo1.Send(False, s1.UserName)
Set pdoc1=db1.getprofiledocument("SentHello")
Call pdoc1.replaceitemvalue("SentHello", "1")
End If
End Sub