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

Hello,
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:
image
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”).event.file.name
if filePath != None:
fileName = self.getSibling(“FileUpload”).event.file.name
fileData = self.getSibling(“FileUpload”).event.file.getBytes()
smtp = “"
sender = "
"
subject = “New ignition feedback”
body = self.getSibling(“TextArea”).props.text
recipients = ["********@
******”]
system.net.sendEmail(smtp, 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
Johannes

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).

4 Likes

Thanks a lot. That worked…