I’m trying to solve how best to do this thing. On posting a purch order, an email should be sent as the purch orders as an PDF attachment using X++. There should be no interaction on the emailing process.
SysInetMail class should be sufficient, but the attachment itself is troubling me.
Is it possible to to create the report and attach it without first saving it to disk? If so, how?
I have done this in the past using the Sysmailer class.
I dont think you can add files as attatchments without first generating and saving them to the disk, but you can use the WinAPI::GetTempPath()(Or use som other more specific path) method when saving and then WinApi::DeleteFile() delete the files after they have been sent.
I don’t believe so. “Printing” the report as a PDF is what generates the PDF and it needs to be saved somewhere, then attached. You should use temporary directories and/or delete the file afterwords. The SysInetMail class is designed to attach files from locations too…
// — Lock the print job settings so can’t be changed in X++ to the screen
printJobSettings.lockDestinationProperties(true);
rr.printJobSettings(printJobSettings.packPrintJobSettings());
rr.run();
Look here for how to use temp folders. You just save to the default temp directory, send the email, then delete the temporary file. I know the feeling you have where you want to just go direct to something but you’re going to have to use temp folders.
Customers can be a pain, but I wouldn’t use parameters. Use winApi::getTempPath() or winApiServer::getTempPath() to get the default temp directory, save the file, then immediately delete it. I don’t see how it could go wrong.