public ActionResult SendReports() { DateTime date = DateTime.Now; string reportDateTime = date.ToString("d", _culture); //TODO get config from web.config ReportConfig reportConfig = new ReportConfig(); reportConfig.DeviceInfo = "<DeviceInfo>" + " <OutputFormat>Excel</OutputFormat>" + " <PageWidth>11in</PageWidth>" + "</DeviceInfo>"; reportConfig.ReportServerUrl = new Uri(@"http://puketi/ReportServer_SQL2012EXPRESS"); reportConfig.ReportPath = "/ICMS/OrdBySalAreaSum_ICMS"; reportConfig.SaveTo = @"C:\RenderedReports\ICMSOrderSummaryReport.xls"; reportConfig.SaveFormat = "Excel"; _reportService.RenderReport(reportConfig); IList<ReportRecipient> recipients = _reportRecipientRepository.GetList(); foreach (ReportRecipient recip in recipients) { Email email = new Email(); email.Attachments.Add(reportConfig.SaveTo); email.To = recip.Email; email.From = "*****@*****.**"; //TODO get from config email.Subject = "ICMS Order Summary Report"; //TODO get from config email.Message = "Order report attached."; _emailService.Send(email); } return Content(string.Format("Successfully sent {0} reports", "1")); }
private ReportConfig SetupReportConfig() { ReportConfig reportConfig = new ReportConfig(); reportConfig.DeviceInfo = "<DeviceInfo>" + " <OutputFormat>Excel</OutputFormat>" + " <PageWidth>11in</PageWidth>" + "</DeviceInfo>"; reportConfig.ReportServerUrl = new Uri(@"http://puketi/ReportServer_SQL2012EXPRESS"); reportConfig.ReportPath = "/ICMS/OrdBySalAreaSum_ICMS"; reportConfig.SaveTo = @"C:\RenderedReports\ICMSOrderSummaryReport.xls"; reportConfig.SaveFormat = "Excel"; return reportConfig; }