我有一个填写在Domino
服务器上的联系表单。提交表单后,我想向用户发送自动回复,确认收到。
我想使用LotusScript
创建回复,从提交的表单中提取某些数据,例如电子邮件地址,联系人姓名。
有人可以建议我如何获取提交文档的ContactName
/ EmailAddress
(而不是test@gmail.com)字段的值,并使用它们来构建回复电子邮件?我对LotusScript
:
Sub Initialize
Dim Session As New NotesSession
Dim db As NotesDatabase
Dim email As NotesDocument
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set email = db.CreateDocument
email.form="Memo"
email.principal="noreply@test.com@test"
email.from="noreply@test.com"
email.inetfrom="noreply@test.com"
email.subject="Email Confirmation"
email.body="Dear ..."
Call email.Send(False,"test@gmail.com")
End Sub
答案 0 :(得分:2)
如果您的代码进入代理商和代理商,那么您可以从UnprocessedDocuments- Property获取当前文档:
Dim dc as NotesDocumentCollection
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
如果从任何表单事件调用代码,那么通常你有一个Source作为NotesUIDocument,如果没有,你可以从打开文档中获取它:
Dim ws as New NotesUIWorkspace
Dim uidoc as NotesUIDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
'- alternative, if from event in open document,
'- where Source is always a Parameter of type NotesUIDocument
Set doc = Source.Document
之后,您可以通过项目名称从文档中获取值:
strMailAddress = doc.GetitemValue( "EmailAddress" )(0)
strContactName = doc.GetitemValue( "ContactName" )(0)
email.SendTo = strMailAddress
email.Body = "Dear " & strContactName & ", asfdsdfds"
UnprocessedDocument- Collection由代理属性定义。如果它是“所有新文档,那么它将包含自上次运行以来新的所有文档。
通过在while循环中包装代码来遍历集合:
Set doc = dc.Getfirstdocument
while not doc is nothing
'Your old code goes here
Set doc = dc.GetNextDocument(doc)
Wend