This is a migrated thread and some comments may be shown as answers.

New to Telerik Reoporting

5 Answers 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stuart
Top achievements
Rank 1
Stuart asked on 01 Feb 2012, 12:50 PM
Hi,
  I am new to telerik reporting. I have gone through some of your videos and tutorials. I have some questions regarding what is the best way to use Telerik reporting for my purposes. Hope i get the answers here;

1. I have a requirement where at the end of each day i need to email invoices to different people(dynamic list) whose email ids should be picked from a table in the database. I understand that we can create invoicing reports in telerik. But i would like to email this report in pdf format to a list of people (and the list of email ids is fetched from the database). Can this be done? if yes, then how. Can you point me in the right direction.

based on what i have read, I think i should do the following:
1. Create a report in telerik reporting as a class library
2. Then create a c# console application which should render the above report into a pdf format and then email to people

Is this the right way to do it. Is there any other better way where we can automatically achieve this without writing any c# application.

please an any body help me on this.


Thanks

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 01 Feb 2012, 06:18 PM
Hello Daniel,

You have correctly presumed you can export the reports programmatically and send the emails. Generally Telerik Reporting is an embedded reporting solution and doesn't support out of the box batch processing and emailing, however it can be easily implemented. To export a report, you can use the RenderReport method of the ReportProcessor class. This method converts the contents of the report to a byte array in the specified format, which you can then use with other classes such as MemoryStream or FileStream. More information is available in Exporting Report Programmatically help article. 

All the best,
Peter
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Gerry Connolly
Top achievements
Rank 1
answered on 19 Jan 2013, 09:24 AM
Hi Peter

I really like Telerik reports, do you know if they are any sample projects or blogs to do the following.
We have a report that produces statements for customers accounts, we would like to batch email this statement to the individual customers as a PDF.  The customers email address are held in a database.  Programatically, is this possible in Telerik.

Thanks

Gerry
0
Steve
Telerik team
answered on 21 Jan 2013, 08:10 AM
Hello Gerry,

The help articles that my colleague referred to in previous reply contain all the information you need to export a report programmatically. As for emailing the exported report to your clients, you can refer to this code library: Send Telerik Report as email attachment.

Kind regards,
Steve
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Adil
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 09 Feb 2016, 10:27 AM
I checked the all the posts but i cant find actual solution ??
 Also i read this blog too but it explains very very plain and i download that project that one is now working and its for web form i'm using MVC 
 I think its impossible to send report as attachment in mail
here i found some thing 
I'm sending parameters from ajax
     var ident = $('#identCE').val();
    var viewer = $("#reportViewer2").data('telerik_ReportViewer');
    var postData = {
        report1: viewer.reportSource($.extend({}, viewer.reportSource(), { report: "CustomerEnrollment.trdx", parameters: { 'CustomerId': ident } }))
    };
    var url = '../AccountMaint/MailReport';
    $.ajax({
        url: url,
        type: "POST",
        dataType: 'json',
        data: postData,
        success: function (data) {
        }

    });

and then catch on MVC controller

        public void MailReport(Telerik.Reporting.Report report1)
        {

            string mimeType;
            string extension;
            Encoding encoding;

            byte[] reportBytes =
            ReportProcessor.Render("PDF", report1, null, out mimeType, out extension, out encoding);

            MemoryStream ms = new MemoryStream(reportBytes);
            ms.Position = 0;

            Attachment attachment = new Attachment(ms, report1.Name + "." + extension);
            MailMessage msg = new MailMessage("pro@gmail.com", "sc@pro.com.tr", "Test Report", "Report Is Attached");
            msg.Attachments.Add(attachment);
            SmtpClient client = new SmtpClient();
            client.Send(msg);

        }

but report1 is object but its not getting report so in mail attachment report is empty!!!

Help me please
0
Stef
Telerik team
answered on 11 Feb 2016, 04:34 PM
Hello Adil,

The HTML5 Viewer's reportSource does not contain a report instance. The reportSource is a description of the report and the parameters the client wants to use for that report. This information is sent to the Reporting REST service to be handled on the server, where the service creates an instance of the report.
For more details check How to: Set ReportSource for Report Viewers (HTML5 Viewer).

In your case you can post the information from the viewer's reportSource.report (string) to your own controller's action. In code you can determine which report to instantiate and export programmatically. Once you have the document's bytes, you can add them as an attachment to an e-mail.


I hope this information is helpful.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Stuart
Top achievements
Rank 1
Answers by
Peter
Telerik team
Gerry Connolly
Top achievements
Rank 1
Steve
Telerik team
Adil
Top achievements
Rank 1
Iron
Veteran
Iron
Stef
Telerik team
Share this question
or