< Back

Document Subject: Send Uploaded attachment via email
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#EmailAttachment or http://A555F9/nn.nsf/ByAlias/EmailAttachment

How to create a web form that allows people to upload a file and send it to you.




This should be stuck in the webquerysave agent of a form that has a file upload control on it.

Dim db As notesdatabase
Dim s As New notessession
Set db = s.currentdatabase
Dim doc As notesdocument
Set doc = s.documentcontext


Dim obj As notesembeddedobject

vFilenames=Evaluate("@AttachmentNames",doc)
sFilename=vFilenames(0)

Print "File:"; & sFilename
Print "getting...<br>"
Set obj=doc.getattachment(sFilename)
Print "extracting...<br>"
Call obj.extractfile("c:\TEMP\" & sFilename)


Print "Done"

Dim mdoc As New notesdocument(db)
mdoc.form="Memo"
Print "b4sub<br>"
mdoc.subject="Blah "
mdoc.sendto="Adam Foste"

Print "b4rt<br>"
Dim rt As New notesrichtextitem(mdoc,"Body")
Call rt.appendtext("Msg with attach.")
Print "b4new<br>"
Call rt.addnewline(1)
Print "b4embed<br>"
Set object = rt.EmbedObject _
( EMBED_ATTACHMENT, "", "c:\TEMP\" & sFilename, sFilename )
Print "b4embed<br>"
Call rt.addnewline(1)
Print "b4embed<br>"
Call mdoc.send(False)

Kill "c:\TEMP\" & sFilename
End