Community & Support
Skip Navigation LinksHome / Community & Support / Code Library / Telerik Reporting > General and Integration Projects > Send Telerik Report as email attachment

Not answered Send Telerik Report as email attachment

Feed from this thread
  • David Silveria Master avatar

    Posted on Jul 4, 2008 (permalink)

    Requirements
    Telerik Reporting version
     Q2 2009 SP1+
    .NET version  2.0 +
    Visual Studio version  VS2005+
    programming language  C#
    To convert code Telerik online converter

    PROJECT DESCRIPTION
    The Report Viewers (Win and Web) do not support sending of reports via e-mail out-of-the-box. To mail a report you have to first render the report into a convenient format and then attach it to a mail message. Here is a possible way of how to achieve this by using the SmtpClient object:

    void MailReport(Telerik.Reporting.Report report, string from, string to, string subject, string body)
           {
               ReportProcessor reportProcessor = new ReportProcessor();
               RenderingResult result = reportProcessor.RenderReport("PDF", report, null);
     
               MemoryStream ms = new MemoryStream(result.DocumentBytes);
               ms.Position = 0;
     
               Attachment attachment = new Attachment(ms, report.Name + ".pdf");
               MailMessage msg = new MailMessage(from, to, subject, body);
               msg.Attachments.Add(attachment);
               //smtp host is the name or IP of the host computer used for sending the email
               string smtpHost = "255.255.255.0";
               SmtpClient client = new SmtpClient(smtpHost);
               client.Send(msg);
           }

    You can find attached a sample project that shows the above code in action.

    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / Telerik Reporting > General and Integration Projects > Send Telerik Report as email attachment