File attachment in XForm

Vote:
 

I have been looking for a solution to upload files to a XForm and then attach the files to an email.

I have followed this blog http://world.episerver.com/Blogs/Anders-Hattestad/Dates/2013/1/Upload-within-Xform/ and have managed to get the upload of the files to work.

The problem is that I am not sure how to get the files that has been uploaded to the form and have them attached when sending the email.

I am trying to add a SendMail-fuction to the XForm_BeforeSubmitPostedData event in the Global.asax.cs.

Anyone who has some example code that I can look at?

#90241
Sep 04, 2014 11:22
Vote:
 

If it's necessary that the file is sent as an attachment, I think it's better that you create your custom e-mail sending that is populated with the incoming data from your XForm.

If you can survice without the attachment you can add a link to the file on your webserver as an extra field inside the XForm data.

#90243
Sep 04, 2014 12:06
Vote:
 

Thanks for your reply! I beleive I want the files sent as an attachment. The problem is that I am not sure how to populate my email function with the incoming data from the XForm. Any examples how to populate it? Especially how to populate it with the uploaded files. The files are now uploaded to a seperate VPP folder as in the example in the blog  http://world.episerver.com/Blogs/Anders-Hattestad/Dates/2013/1/Upload-within-Xform

#90252
Sep 04, 2014 13:27
Vote:
 

You can hook up to the XForm_AfterSubmitPostedData and iterate eventArgs.FormData.GetValues() that is a NameValueCollection

If I remember correctly, each value in the NameValueCollection represents a field in your XForm
Add each value to your e-mail body.

#90266
Sep 04, 2014 15:03
Vote:
 

Thanks! I will try that out and see if it works.

#90267
Sep 04, 2014 15:12
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.