Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to dynamically send a report via e-mail as a PDF

$
0
0

This example illustrates how to automatically send a report via e-mail. To do this, a report should first be exported into one of the available formats. In this example, a report is exported to PDF, since this format provides the best output quality (the PDF result is as close to a report's print result as possible).

See also:
How to send a report as HTML in an email body

Question Comments

Added By: MohammedFarooq at: 10/20/2015 1:11:44 PM    

Hi,
I am getting the following error when the button is clicked. For your information, i am executing this logic in XAF viewcontroller SimpleAction button execute event

Error sending a report.
System.Exception: Null object cannot be converted to a value type. ---> System.Exception: Null object cannot be converted to a value type. ---> System.InvalidCastException: Null object cannot be converted to a value type.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at DevExpress.XtraReports.UI.XRSubreport.ApplyParameterBindings()
at DevExpress.XtraReports.UI.XRSubreport.OnBeforePrint(PrintEventArgs e)
at DevExpress.XtraReports.UI.XRControl.GetPrintableBrick(XRWriteInfo writeInfo)
at DevExpress.XtraReports.UI.XRControl.WriteContentTo(XRWriteInfo writeInfo)
at DevExpress.XtraReports.UI.Band.GenerateContent(DocumentBand docBand, Int32 rowIndex, Boolean fireBeforePrint)
at DevExpress.XtraReports.UI.Band.GenerateContentAndDecompose(DocumentBand docBand, Int32 rowIndex, Boolean fireBeforePrint)
at DevExpress.XtraReports.UI.Band.CreateDocumentBand(Int32 rowIndex, RootDocumentBand rootDocBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraReports.UI.DetailBand.CreateDocumentBand(Int32 rowIndex, Int32 rowCount, RootDocumentBand rootDocBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraReports.Native.Printing.DetailWriterBase.WriteDetailCore(PageBuildInfo pageBuildInfo)
at DevExpress.XtraReports.Native.Printing.DetailWriterBase.Write(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraReports.Native.Printing.DocumentBuilder.GetBand(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraPrinting.Native.DocumentBand.GetBand(PageBuildInfo pageBuildInfo)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.CanProcessDetail(DocumentBand rootBand, PageBuildInfo pageBuildInfo)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBand(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBand(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBand(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillPageRecursive(DocumentBand rootBand, DocumentBand docBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBandCore(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBand(DocumentBand rootBand, RectangleF bounds, RectangleF newBounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPageForBands(DocumentBand rootBand, RectangleF bounds, ProcessBandsDelegate process)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillReportDetails(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageHeaderFooterRowBuilderBase.FillReportDetailsAndFooter(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageRowBuilderBase.FillPage(DocumentBand rootBand, RectangleF bounds)
at DevExpress.XtraPrinting.Native.PageBuildEngine.Build()
at DevExpress.XtraPrinting.Native.PageBuildEngine.BuildPages(DocumentBand rootBand, Boolean clearGroupingInfo)
--- End of inner exception stack trace ---
at DevExpress.XtraPrinting.PrintingSystemBase.OnCreateDocumentException(ExceptionEventArgs args)
at DevExpress.XtraPrinting.Native.PageBuildEngine.RaiseCreateDocumentException(Exception exception)
at DevExpress.XtraPrinting.Native.PageBuildEngine.BuildPages(DocumentBand rootBand, Boolean clearGroupingInfo)
at DevExpress.XtraPrinting.Native.DocumentHelper.BuildPagesCore()
at DevExpress.XtraPrinting.Native.DocumentHelper.BuildPages()
at DevExpress.XtraPrinting.Native.PrintingDocument.BuildPages()
at DevExpress.XtraPrinting.Native.PrintingDocument.End(Boolean buildPagesInBackground)
at DevExpress.XtraPrinting.PrintingSystemBase.End(Boolean buildPagesInBackground)
at DevExpress.XtraReports.UI.XtraReport.CreateDocumentCore(PrintingSystemBase ps, Single progressRange, Boolean buildPagesInBackground)
at DevExpress.XtraReports.UI.XtraReport.CreateDocument(Single progressRange, Boolean buildPagesInBackground, Boolean suppressClearDataContext)
at DevExpress.XtraReports.UI.XtraReport.TryCreateDocument(Single progressRange, Boolean buildPagesInBackground, Boolean suppressClearDataContext)
--- End of inner exception stack trace ---
at DevExpress.XtraPrinting.PrintingSystemBase.OnCreateDocumentException(ExceptionEventArgs args)
at DevExpress.XtraReports.UI.XtraReport.TryCreateDocument(Single progressRange, Boolean buildPagesInBackground, Boolean suppressClearDataContext)
at DevExpress.XtraReports.UI.XtraReport.CreateIfEmpty(Single progressRange, Boolean buildPagesInBackground)
at DevExpress.XtraReports.UI.XtraReport.ExportToPdf(Stream stream, PdfExportOptions options)
at DevExpress.XtraReports.UI.XtraReport.ExportToPdf(Stream stream)
at Solution6.Module.vcPayroll.SimpleAction1_Execute(Object sender, SimpleActionExecuteEventArgs e) in E:\My Docs\Projects\Solution6\Code\Solution6.Module\BusinessObjects\10 Payroll\Payroll Run\vcPayroll.vb:line 179

Added By: MohammedFarooq at: 10/20/2015 1:12:27 PM    

The error happens at this line

report.ExportToPdf(mem)

Added By: Ingvar (DevExpress Support) at: 10/21/2015 1:28:10 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T302655: NullReferenceException when trying to apply solution described in E16. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>