Greetings everybody,
I am trying to send an e-mail with attachment from Aris. I am using this class:
http://www.ariscommunity.com/users/amol/2011-10-11-how-send-email-using-aris-script
Problem is that I can not determine the path for the report file output. I work with XlsWorkbook class that has no method to get a path to the file. Report seems to be working with the file in temp directory, where I can't figure out where the file is saved.
I can change the final destination of the output, but this will save workbook at the end of the script runtime. Meaning I would have to create one report to export data into the file and the other to send this saved file via e-mail message.
Any ideas will be appreciated. Thank you.
Martin
Hello!
Try to do following:
//Folder and name of the file to be attached (on the server) sFolder = "C:\Temp\"; sFileName = "Attachment.xls"; //Creates Excel oExcel = Context.createExcelWorkbook ( sFileName ); //Add content oExcel.write(); //Writes to output location. //Bytes array of the file. oData = Context.getFile (sFileName, Constants.LOCATION_OUTPUT); //save to your work folder on server oFile = new java.io.File(sFolder+sFileName); oOS = new java.io.FileOutputStream(oFile); oOS.write(oData); oOS.close();
And now you can use file sFolder+sFileName in the JavaMail.
Hope, this helps.
BR, Ilya.
Hello
I am trying to change the save location of the report file.
But in my case I am using the xml file
I try to do this:
function outputFileToFolder( folderName, fileName, oData ) {
var oFile = new java.io.File(folderName+fileName);
var oOS = new java.io.FileOutputStream(oFile);
oOS.write(oData); // Error: nullPointerException, because oData is empty
oOS.close();
}
function main() {
var xmlOutput = Context.createXMLOutputObject(Context.getSelectedFile(), "Root");
//then I fill the file with content using methods "addElement" and "setAttribute"
//at the end I do this:
Context.addOutputFileName ("101.xml");
xmlOutput.WriteReport(); // it's default folder
var oData = Context.getFile("101.xml", Constants.LOCATION_OUTPUT); // <- oData // is null, because file "101.xml" not apeared in default folder
outputFileToFolder( "C://TEMP//output", "Data.xml", oData ); // it's my folder
}
But I get error nullPointerException.
Tell me please how can I solve this problem?