I have a Telerik Report to produce monthly invoices. When I run the invoices into a Telerik Report Viewer, it works great.
If I use the same Report with RenderReport to run the invoices into a PDF document to
be emailed, the PDF consists of the report's header logo, and the footer
datetime and page number. The center section (retrieved from the
database) is blank. I'm not sure what I'm doing wrong. I've verified
that the parameters passed are correct and the same as the ones passed
into the Report Viewer. Any help would be appreciated.
private string SendOutInvoiceEmails(DateTime dtStartDate, Int16 intFinalInvoice, Int16 intFacility)
{
var typeReportSource = new Telerik.Reporting.TypeReportSource();
typeReportSource.TypeName = "TelerikReports.InvoiceMaster, TelerikReports";
typeReportSource.Parameters.Add("RID", rdr["Resid"]);
typeReportSource.Parameters.Add("RDM", dtStartDate.Month);
typeReportSource.Parameters.Add("RDY", dtStartDate.Year);
MailReport(typeReportSource, "admin@rexxrally.com", recRes.email_address, "Monthly Invoice For " + dtStartDate.ToString("MMM") + ", " + dtStartDate.ToString("yyyy"), "Here is your monthly invoice.", rdr["resid"].ToString());
}
void MailReport(Telerik.Reporting.ReportSource rptSource,
string from,
string to,
string subject,
string body,
string ResID)
{
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", rptSource, null);
MemoryStream ms = new MemoryStream(result.DocumentBytes);
ms.Position = 0;
Attachment attachment = new Attachment(ms, "Invoice" + ResID + ".pdf");
MailMessage msg = new MailMessage(from, to, subject, body);
msg.Attachments.Add(attachment);
SmtpClient smptClient = new SmtpClient();
smptClient.Credentials = CredentialCache.DefaultNetworkCredentials;
smptClient.Send(msg);
}
If I use the same Report with RenderReport to run the invoices into a PDF document to
be emailed, the PDF consists of the report's header logo, and the footer
datetime and page number. The center section (retrieved from the
database) is blank. I'm not sure what I'm doing wrong. I've verified
that the parameters passed are correct and the same as the ones passed
into the Report Viewer. Any help would be appreciated.
private string SendOutInvoiceEmails(DateTime dtStartDate, Int16 intFinalInvoice, Int16 intFacility)
{
var typeReportSource = new Telerik.Reporting.TypeReportSource();
typeReportSource.TypeName = "TelerikReports.InvoiceMaster, TelerikReports";
typeReportSource.Parameters.Add("RID", rdr["Resid"]);
typeReportSource.Parameters.Add("RDM", dtStartDate.Month);
typeReportSource.Parameters.Add("RDY", dtStartDate.Year);
MailReport(typeReportSource, "admin@rexxrally.com", recRes.email_address, "Monthly Invoice For " + dtStartDate.ToString("MMM") + ", " + dtStartDate.ToString("yyyy"), "Here is your monthly invoice.", rdr["resid"].ToString());
}
void MailReport(Telerik.Reporting.ReportSource rptSource,
string from,
string to,
string subject,
string body,
string ResID)
{
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", rptSource, null);
MemoryStream ms = new MemoryStream(result.DocumentBytes);
ms.Position = 0;
Attachment attachment = new Attachment(ms, "Invoice" + ResID + ".pdf");
MailMessage msg = new MailMessage(from, to, subject, body);
msg.Attachments.Add(attachment);
SmtpClient smptClient = new SmtpClient();
smptClient.Credentials = CredentialCache.DefaultNetworkCredentials;
smptClient.Send(msg);
}