Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Possible to attach SSRS report as PDF to email?

I built my first SSRS report. We have 2 requirements

1. Send the SSRS report in form of PDF to *internal users*. To do this, I email the internal users a link to the SSRS report in PDF format. I also email them a link to the actual report to view it on the report server.

2.  We have to email the report to external users/clients. I can't give them a URL in email. The report has to be in PDF format, attached to the email.

I can get the report in PDF format using the SSRS URL with "PDF" as the format. But, anyway I can attach this to an email? Someone here said I need to use memory stream.

This is MVC/ C#/ SQL 2015.
Avatar of Russell Fox
Russell Fox
Flag of United States of America image

Easiest is to set up a subscription on your SSRS site, selecting the PDF output. If you can't do that, you may need to do something fancy like specify a file share as the output location and set up some other code to iterate over the files and email them on-demand:
User generated image
Avatar of Camillia

ASKER

Thanks. Another question...if it's a subscription, how do I attach it to the email? how do I get to it..where is it stored?

OR, is it automatically emailed?? Looks like it's automatically emailed. Correct? if so, how can I specify who to email it to? We have specific users per PDF we need to email to.
I don't think we can have an email Subscription here. Each PDF has a specific set of users that needs to PDF to go to.

Now, my coworker says SSRS has web services, we can call it and get the PDF in binary format and then use memory stream to save it in database or convert it to PDF in code and attach it. Is that correct? I'll Google but is that correct?
This is what someone else says here

"what I remember you can create the PDF file consume the file and convert into byte array and store that as binary in db....



I don't know if there is a built in function of the webservice that will return it as a binary string
something like this:
string sTargetURL = "http://stl-sql-01/TulNasrvr?" + "/EmpTmpHrs&rs:Command=Render&rs:format=PDF&ReportParam=" + ParamValue; HttpWebRequest req = (HttpWebRequest)WebRequest.Create( sTargetURL ); req.PreAuthenticate = true; req.Credentials = new System.Net.NetworkCredential( strReportUser, strReportUserPW, strReportUserDomain ); HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse(); Stream fStream = HttpWResp.GetResponseStream();
then you can store that fStream object in the database"
ASKER CERTIFIED SOLUTION
Avatar of Russell Fox
Russell Fox
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, Russell. I think I have to a have .net application. But I'll look at subscriptions as well.
You can check this article. It might give you another option for a data driven subscription without Enterprise edition: https://sqlswimmer.wordpress.com/2014/07/01/data-driven-subscriptions-1/

There are also inexpensive 3rd party tools , which  can handle data driven subscriptions. This one is a good example : http://www.r-tag.com/Pages/ReportManager.aspx
Thanks, I'll take a look