Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Send Uploaded attachment via email

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#EmailAttachment or http://www.notesninjas.com/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

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
man and boy by Tony Parsons
British book of the year 2000. Great book, hard to put down, but I nearly threw it away half way through. You'll know why when you read it.
See at: Amazon.co.uk | Amazon.com |