例如:下例中的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