Attach multiple uploaded files from subform in email

Attach multiple uploaded files from subform in email

I want to attach multiple files that have been uploaded in a subform to a particular record in my email.

The code im using is below, I know this is close  but it doesn't seem to work when i put the variable holding the files uploadfilecvar into the  attachments :file: part of the email.


If I use   attachments :file:  file.File_upload
then only one of one file is attached. How can i get this to email all of the files attached to a single email?

If i put  sendmail inside the for loop then it will send 3 emails, I will get all the attachments but also 3 emails!

The error I get is  uploadfilevar does not exist in Approve

Approve is the form this code is in.

How can i put a variable in the attachments part or is there another way to do this?

  1. request = Purchase_Request_Form[ID == input.Request_ID];
  2. uploadfilevar = "";
  3. for each file in request.Build_Files
  4.     {
  5. uploadfilevar =  uploadfilevar + file.File_upload;
  6. }
  7. if(input.Email_Factory_Request)
  8. {
  9. sendmail
  10. [
  11. from:"email@email.com"
  12. to:"email@email.com"
  13. subject:"subject"
  14. message:"message"
  15. content type:HTML
  16. attachments :file: uploadfilevar
  17. ]
  18. }