简体   繁体   English

从Windows Service应用程序发送报告

[英]Send reports from Windows Service application

I have to send a Reporting Services Report report (or crystal report) periodically every N minutes via email. 我必须每隔N分钟通过电子邮件定期发送一次Reporting Services报告报告(或水晶报告)。

I don't have the SQL Reporting Server, it is a stand-alone application. 我没有SQL Reporting Server,它是一个独立的应用程序。 They want to receive the reports in their inbox as a PDF or XLS file. 他们希望以PDF或XLS文件形式在收件箱中接收报告。

How I could do that using a console app or a Windows service app ? 我如何使用控制台应用程序Windows服务应用程序来做到这一点? Is that possible? 那可能吗?

I assume that you can generate reports. 我假设您可以生成报告。 Or else if you wish to create reports in xls format, without using the MS SQL Reporting services or Crystal report, you can get it done using Microsoft.Office.Interop.Excel dll. 或者,如果您希望以xls格式创建报表,而不使用MS SQL Reporting服务或Crystal报表,则可以使用Microsoft.Office.Interop.Excel dll来完成它。 You may configure a physical path (in your app.config file) where the generated reports are saved. 您可以(在app.config文件中)配置用于保存生成的报告的物理路径。 In your windows service you can send emails in a time interval. 在Windows服务中,您可以按时间间隔发送电子邮件。 You can select the xls file (report) which you have already created, send it along with the email as an attachment. 您可以选择已经创建的xls文件(报告),并将其与电子邮件一起作为附件发送。 For that you can use the System.Net.Mail.SmtpClient class. 为此,您可以使用System.Net.Mail.SmtpClient类。 (For more details - http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx ) (有关更多详细信息,请访问http://msdn.microsoft.com/zh-cn/library/system.net.mail.smtpclient.aspx

When you are creating the email message you may configure the smtp server, from and to addresses and the time interval of the windows service in your App.config file as preferred. 在创建电子邮件时,您可以根据需要配置smtp服务器的地址和Windows服务的时间间隔,以及从该地址到Windows服务器的时间间隔。 Hope this helps. 希望这可以帮助。

PS I have got the sample code of creating a xls files using Microsoft.Office.Interop.Excel assembly. PS我有使用Microsoft.Office.Interop.Excel程序集创建xls文件的示例代码。 If you need I would like to share. 如果需要,我想分享。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM