Telerik blogs

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 programmatically 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)   
      string mimeType;   
      string extension;   
      Encoding encoding;   
      byte[] reportBytes =   
      ReportProcessor.Render("PDF", report, nullout mimeType, out extension, out encoding);   
      MemoryStream ms = new MemoryStream(reportBytes);   
      ms.Position = 0;   
      Attachment attachment = new Attachment(ms, report.Name + "." + extension);   
      MailMessage msg = new MailMessage(from, to, subject, body);   
      SmtpClient client = new SmtpClient(smptHost);   


You can find a sample report with both Win and Web apps that show the above code at work in this code library project. You can use our Code Converter to convert this to VB.NET if needed.


Telerik Blogging Ninja
About the Author

The Telerik Team


Related Posts


Comments are disabled in preview mode.