I want to be able to forward a document displayed in a web browser to both Notes and non-Notes users exactly the same as can be achieved from the Notes Client using @Command([MailForward]); i.e. I want the email to contain the layout and information as it appears in the form.
Looking at other topics in this forum it seems the advice is to create an agent and call it from the WebQuerySave form event. I tried this using this code:
Set doc = session.DocumentContext
Call doc.Send(False, "Gary McMahon")
Note that I do not attach the form as this is intended for users of non-Notes mail clients. Having done this my notes mail database reports it cannot find the form of course. But if I do attach the form presumably non-Notes people won’t be able to view it.
The MailForward command appears to create a standard memo with all the fields etc from the original represented in the main Body field. This is what I want to achieve.
Subject: Forwarding a document from a web form
In the Notes client, Forward is implemented using the NotesDocument.RenderToRTItem method. You’ll need your agent to create a new document, set the form to “Memo”, create a new rich text field on the document, and call RenderToRTItem on the current document. Then send the new document. That said, I doubt if it works on the web.
Something like this (untested):
Sub Initialize
On Error Goto errhand
Dim s As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim mailDoc As notesdocument
Dim body As notesrichtextitem
Set db = s.currentdatabase
Set doc = s.documentcontext
Set mailDoc = db.CreateDocument
'change the values of the following fields to your From and SendTo info
mailDoc.Principal = "ClassRegistrationSystem"
mailDoc.ReplyTo = "ClassRegistrationSystem"
mailDoc.From = "ClassRegistration System/McDougal/hmco"
mailDoc.SendTo = doc.Name(0)
mailDoc.Subject = doc.Title(0)
mailDoc.Form="Memo"
Set body = New NotesrichtextItem(mailDoc,"Body")
Call doc.RenderToRTItem(body)
Call mailDoc.Send(False)
'do whatever you want here to return the user to another page, or just print text
Print "<p>Thanks for forwarding your document</p>"
Exit Sub
errhand:
Print "<p>autoApprove error at line " & Erl & ": " & Error & "</p>"
Print "<p>Please note this error string in any problem report you submit." & "</p>"
Print "<p><a href=javascript:window.close();>Close window</a>" & "</p>"
Exit Sub
End Sub
Subject: Forwarding a document from a web form
Try this:
Create a SendTo and Subject field on your form and populate those with the intended recipient and the subject of the memo.
Then, from your agent that was called via WebQuerySave, use the following:
Call doc.Send(True)
This will send the document to the name(s) listed in the SendTo field.
See if that helps.
-JS