The previous article describes how to subscribe to a report as a shared directory in SSRS. Because SSRS is special to subscribe to a report in the form of a message, this article describes how to implement a report mail subscription in a flexible manner.
To subscribe to a report by implementing a message, we split it into three parts.
We use the SQL Server Agent generation job to trigger a process in a fixed cycle. Then in this process, you first implement an app to generate the report into a specified directory, and then call another program, according to the configuration file, send the report to the users of the specified mail group.
First, create the application that generates the report PDF.
The main idea to build a PDF is to add a ReportViewer control with a WinForm application and then generate the report directly into PDF format.
Open Visual Studio 2012 to create an WinForm application.
Add the ReportViewer control on the form.
Then, create a few tables in the database to hold the configuration information for the report control and the configuration information sent by the message. The structure of these three tables can be defined according to the actual situation, in this film, reportbase mainly save ReportServer and reportpath two pieces of information, used to locate a server-side report. Emailbase is primarily used to record all user names and passwords for outgoing messages and the address of the SMTP server. Reportto is used to record who the mail is sent to.
Once you have created the underlying table, go back to the project and add a LINQ to SQL Classes (you can choose Entity Data Model, of course).