Sending an e-mail with an attachment to a recipient using the file upload component and a send button

I am currently having problems sending an e-mail via a button that attaches the document which was uploaded in the file upload component. Something like this:
If i directly use a onfileRevieve script on the file upload component everything works.
But i don’t know how to access the uploaded data in the fileUploadComponent through the button.

I had something in mind like following script for the button:
filePath = self.getSibling(“FileUpload”)
if filePath != None:
fileName = self.getSibling(“FileUpload”)
fileData = self.getSibling(“FileUpload”).event.file.getBytes()
smtp = “"
sender = "
subject = “New ignition feedback”
body = self.getSibling(“TextArea”).props.text
recipients = ["********@
******”], sender, subject, body, 0, recipients, [fileName], [fileData])
I know that this doesn’t work but i hope it makes it a bit clearer to understand.

Best regards

You’ll have to save the uploaded file in a temporary location, then retrieve it in the send button’s script. And have a mechanism to clean up the temporary location of abandoned uploads (never sent).


Thanks a lot. That worked…