If you’ve been looking for a way to automatically schedule and email Crystal Reports then there’s a free solution – a combination of crexport, blat, and the Windows Task Scheduler.
crexport – Crystal Reports Exporter is a free Windows Command Line tool which allows you to run reports without Crystal Reports installed. It allows you to export the report as a file or straight to a printer.
blat – Blat is a free Windows Command Line tool that allows you to send emails, with attachments using your existing SMTP (mail) servers.
@echo off ECHO Deleting existing PDF documents del *.pdf for %%f in (%~dp0*.rpt) do ( ECHO Creating PDF report for %%~nf "%~dp0crexport.exe" -F "%~dp0%%~nxf" -O "%~dp0\%%~nf.pdf" -E pdf ECHO Emailing PDF report for %%~nf "%~dp0blat.exe" -body "%%~nf" -to [email protected] -subject "Monthly report for: %%~nf" -attach "%~dp0\%%~nf.pdf" -server MAILSERVER.LOCAL -f [email protected])
Does the report contain prompts? If so, either remove the prompts, hard code the answers to the prompts to read the documentation for crexporter for how to handle crystal reports prompts.
If you get an error message which reads ‘System Error: Could not load file or assembly’ make sure you’ve installed the Microsoft .NET Framework 4 and SAP Crystal Reports runtime engine for .NET Framework 4. 32-bit version or 64-bit version.
If it still doesn’t work, try checking that the report runs using normal Crystal Reports.
Also – I’ve found that using the ‘user’ DSN in the ODBC works when the ‘system’ doesn’t.
Hello, I cannot get it to accept parameters. Eg. I have a vehicle table and I type:
crexport -U crystal -P crystal123 -F Vehicle.rpt -O VehList.pdf -E pdf -a “dbVehicleRegNo:(ABC123)”
or I tried:
crexport -U crystal -P crystal123 -F Vehicle.rpt -O VehList.pdf -E pdf -a “dbVehicleRegNo:ABC123” But I get all the vehicles in the pdf, not only, ABC123.
Please help
This looks to be exactly what I need for a project. But the sample command above seems to have some wierd characters (like %~dp0). Could you post a clean version or the script file itself? Thanks much!
Dante says:those are modifiers… Nothing wrong with the script. I’m sure at 5 years ago, you don’t care… but someone else might.