Hello,
I’m sending emails from Ignition with a xls file attached using the system.dataset.exportExcel function.
Here’s my script :
table=event.source.parent.parent.getComponent('Table')
data=table.data
filePath=system.dataset.exportExcel("File.xls", 1, data)
if filePath != None:
fileName = filePath.split("\\")[-1]
fileData = system.file.readFileAsBytes(filePath)
system.net.sendEmail("smtp.example","test@test.com","Subject","Body",0,["i.mathias@courtoisenergies.fr"],[fileName],[fileData])
I’d like to do the same thing but without prompting the user on where to save the file, just as I’m doing with the printToImage function which automatically saves the file in a temp folder and let me access it through its name rather than its path.
Example :
window = system.gui.getWindow("WindowPath")
name_window = "Test.png"
system.print.printToImage(window,name_window)
fileName = "Test.png"
fileData = fpmi.file.readFileAsBytes(fileName)
system.net.sendEmail("smtp.example","test@test.com","Email de test","Contenu de l'email",0,["i.mathias@courtoisenergies.fr"],[fileName],[fileData])
Maybe this can be done using the system.dataset.dataSetToExcel function? But then I have to use file.writeFile to use the return of this function and specify a path, not just a name… Any idea?