Attachment on web

Hi All,

I want to create a document through agent at run time. I have from “A” which has file upload control and use this control to upload a file on when run this form web. I also want to create a another document whith form “B” which has First Name, Last Name and file which is uploaded on the “A” form. I use document context to get the First Name and Last Name from Form “A” but how could I get uploaded file from “A” Form and attached to document which is from “B” form.

Pls suggest me if any one have an Idea.

With Regards,

Vikas K Sinha

Subject: attachment on web

Perhaps like this in a WebQuerySave-agent for form A:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim docContext As NotesDocument

Dim docB As NotesDocument

Dim embObject As NotesEmbeddedObject

Dim rtItem As NotesRichTextItem

Dim strTempDir As String

Dim vEval As Variant

Set db = session.CurrentDatabase

Set docContext = session.DocumentContext

'-- Create new doc and copy some values.

Set docB = db.CreateDocument

Call docB.ReplaceItemValue(“Form”, “DocB”)

Call docB.ReplaceItemValue(“FirstName”, docContext.GetItemValue(“FirstName”)(0))

Call docB.ReplaceItemValue(“LastName”, docContext.GetItemValue(“LastName”)(0))

Set rtItem = New NotesRichTextItem(docB, “Body”)

'-- This code tries to get the temp-catalog using the ‘Environ’ function.

'-- If the server isn’t a Windows server, you will have to get the catalog for temporary storage in some other manner.

strTempDir = Environ(“temp”)

If strTempDir = “” Then strTempDir = Environ(“tmp”)

If Right$(strTempDir, 1) <> "" Then strTempDir = strTempDir & ""

'-- Get any attachments.

vEval = Evaluate(“@AttachmentNames”, docContext)

ForAll v In vEval

If v <> “” Then

'-- The file must be detached to disk,

'-- then attached to the new document.

Set embObject = docContext.GetAttachment( v )

Call embObject.ExtractFile( strTempDir & v )

Call rtItem.EmbedObject( EMBED_ATTACHMENT, “”, strTempDir & v )

End If

End ForAll

'-- Don’t forget to save.

Call docB.Save(True, False)