Download Report and attach to email

北战南征 提交于 2019-12-08 12:50:40

问题


I would like to ask if anyone knows the thing that i want to do:

I have a report in microsoft report server that's waiting for a parameter (person_id) to make the fulfill.

I need to send an email with the report of each person_id. I need to run a function that runs my report called per_permissions.rdl download it and attached the file to send it by email. Example in vb.net code

strSql = "SELECT per_id,per_email FROM person"
dt_person = getDataTable(strSql)

For each dr_person As DataRow in dt_persona.Rows
 attached_file = mysticFunction(dr_person("per_id"))
 ...
Next

Public Shared Sub DownloadFile(ByVal _URL As String, ByVal _SaveAs As String)
  Try 
    Dim _WebClient As New System.Net.WebClient()
    _WebClient.DownloadFile(_URL, _SaveAs) 
  Catch _Exception As Exception 
    Console.WriteLine("Exception caught in process: {0}", _Exception.ToString()) 
  End Try 
End Sub

回答1:


Yes, it is fairly simple. Using the ReportExecutionService.Render method you can render the report however you want. We've used this to run reports and attach them to emails automatically.

The MSDN site has some code to get you started.

To add a reference to the report execution web service, right-click References, select Add Service Reference... and add a reference to the web service that will look something like:

http://MyReportServer/ReportServer/ReportExecution2005.asmx

You will also need the report service web service, which is:

http://MyReportServer/ReportServer/ReportService2005.asmx


来源:https://stackoverflow.com/questions/25492282/download-report-and-attach-to-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!