Reputation: 29
I am new to SSRS,firstly sorry if this question was already posted,but after fine search i am posting this.
In my Business Intelligence Development studio i am generating SSRS reports and saving them to excel format,everything works till now.But after this i need to email these reports to the client in the run time which i am unable to do because of larger file size.Till now i did this manually.But i need them to be done in run time.I searched a lot of stuff regarding how to compress and Email the report in run time,but in vain i posted this.
Responses with screenshots were appreciated.Thanks in advance.
Upvotes: 0
Views: 2469
Reputation: 4866
Adding a late answer to this in case someone runs into the same scenario.
The way I solved this was to change the SSRS subscription to write to "Windows File Share" instead of email.
This is particularly helpful if your email system has size limits and the file is too large. Also, emailing Excel in SSRS has a row limit of ~65k, but it does not have this limit for the file system if you select Excel and not Excel 2003 (you do not have this choice with email).
Once it is saved on the file system, create a SQL Server job that has two steps:
Zip the file. Use xp_cmdshell and 7-Zip like this for example:
exec master.dbo.xp_cmdshell '"C:\Program Files\7-Zip\7z.exe" a -tzip C:\Reports\MyReports.zip C:\Reports\MyReport.xlsx'
Send the zipped file via Database Mail like this example:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SERVER DBMAIL',
@recipients = '[email protected]',
@subject = 'My Report',
@file_attachments='C:\Reports\MyReport.zip';
Upvotes: 0
Reputation: 20560
You'll have to do this programmatically - that is, write a program that runs a report, renders it to Excel, saves it, compresses it then emails it out.
It sounds hard but is actually quite simple. Using the ReportExecutionService.Render
method you can render the report however you want, so you'd render to Excel, compress the output and attach them to emails.
The MSDN site has some code to get you started.
Upvotes: 1