brjp1
brjp1

Reputation: 9

In Lotusscript, how can I email a form from a button and have all the form data included?

Using this code:

Sub Click(Source As Button)
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Dim doc As NotesDocument
 Set db = session.CurrentDatabase
 Set doc = New NotesDocument( db )
 doc.Form = "hardware1"
 doc.SendTo = "email1"
 doc.Subject = "Here's the document you wanted"
 Call doc.Send( True )
End Sub

I am getting the actual form emailed but no data is included from the form.

Upvotes: 0

Views: 84

Answers (1)

Tode
Tode

Reputation: 12060

In your example code you create a new document with form "hardware1" and send that empty document.

If the code is in a button in the form, then you can get the "current" document using the NotesUiWorkspace:

Dim ws as New NotesUiWorkspace
Set doc = ws.CurrentDocument.Document
'- here comes your send code

Take care: by default the send- command saves the document unless you set the property savemessageonsend to false doc.savemessageonsend=false

In additin the document may get some additional fields by sending it, that you do not want. In that case send a copy of the document:

Dim docMemo as NotesDocument
Dim ws as New NotesUiWorkspace
Set docMemo = New NotesDocument( db )
Set doc = ws.CurrentDocument.Document
Call doc.CopyAllItems( docMemo )
docMemo.Subject = "email"
docMemo.SaveMessageOnSend = False
Call docMemo.Send( True )  

Upvotes: 2

Related Questions