This topic is locked
[SOLVED]

 How to email uploaded attachment(s)?

9/30/2019 9:59:45 AM
ASPRunner.NET General questions
Pete K author

I need to send an email after a record is added to include any uploaded files as attachments. I can see the path of the uploaded files encoded in the data field in some sort of associative array and given enough time I could probably figure out a way to reliably extract the path and file name of x number of files. But my coding skills aren't that great and I'm hoping there might be a robust built-in way to do this. Seems like this would be a common use case. Barring this, does anyone have any code to parse that field they would care to share?

Here's an example of what gets stored in the text field where two files were uploaded:
[{"name":"E:\\WebResources\\webapps_Resource\\Interpreter2/18-19 Interpreter Contract - Spanish_zu2mx1h8.doc","usrName":"18-19 Interpreter Contract - Spanish.doc","size":36352,"type":"application/msword","searchStr":"18-19 Interpreter Contract - Spanish.doc,!translate.doc,!:sStrEnd"},{"name":"E:\\WebResources\\webapps_Resource\\Interpreter2/translate_lw8vdynx.doc","usrName":"translate.doc","size":44,"type":"application/msword"}]

admin 9/30/2019

This some sort of array is a list of uploaded files in JSON format. ASPRunner.NET manual provides an example of working with these data:

https://xlinesoft.com/asprunnernet/docs/rename_uploaded_file.htm

Pete K author 9/30/2019



This some sort of array is a list of uploaded files in JSON format. ASPRunner.NET manual provides an example of working with these data:

https://xlinesoft.co...loaded_file.htm


Thank you, Sergey. That's exactly what I was looking for. I don't know how I missed that in the manual. I actually looked for it but somehow missed that topic.

Pete K author 9/30/2019

For anyone else who might be interested, here is the actual code that I have working to pull this off:

/* get attachments array to pass to runner_mail function

assumes name of db field containing uploaded doc info is Documents

assumes file locations are stored as absolute server paths

otherwise, use something like MVCFunctions.getabspath()

*/
var fileArray = MVCFunctions.my_json_decode(values["Documents"]);

XVar attachments = XVar.Array();

for(int i = 0; i < fileArray.Count(); i++)

{

attachments[i] = new XVar("path",fileArray[i]["name"]);

}


jadachDevClub member 9/30/2019



For anyone else who might be interested, here is the actual code that I have working to pull this off:

/* get attachments array to pass to runner_mail function

assumes name of db field containing uploaded doc info is Documents

assumes file locations are stored as absolute server paths

otherwise, use something like MVCFunctions.getabspath()

*/
var fileArray = MVCFunctions.my_json_decode(values["Documents"]);

XVar attachments = XVar.Array();

for(int i = 0; i < fileArray.Count(); i++)

{

attachments[i] = new XVar("path",fileArray[i]["name"]);

}



Thank you sir!!