Email a Crystal Reports from VB.NET
To send a Crystal Reports document via email, the initial step involves exporting the Crystal Reports to one of the available file formats within Crystal Reports. Once the export is complete, the exported file can then be attached and sent via email.
It is worth noting that all the programming samples provided in these tutorials for Crystal Reports are based on the crystaldb database. Prior to commencing this tutorial, I recommend familiarizing yourself with the structure of the database. To access the database structure, kindly click on the following link: Click here to view the Database Structure.
In this tutorial, we will be utilizing the "Export Crystal Report to PDF file" tutorial as a foundation. Therefore, it is advisable to review the tutorial on exporting Crystal Reports to PDF before proceeding with this section.
After successfully Export Crystal Report to PDF file, the subsequent step involves sending the exported file via email. To accomplish this, we will be utilizing the System.Web.Mail framework. It is imperative to provide the necessary configuration details for the SmtpMail client and attach the exported file as an attachment to the email.
Select the default form (Form1.vb) you created in VB.NET and drag two buttons (Button1, Button2 ) and CrystalReportViewer control to your form.
Select Form's source code view and import the following :
- Imports CrystalDecisions.CrystalReports.Engine
- Imports CrystalDecisions.Shared
- Imports System.Web.Mail
Put the following source code in the button click events
Full Source VB.NETcryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")
The Crystal Report is in your project location, there you can see CrystalReport1.rpt . So give the full path name of report here.
Before you run this programme , you have to provide the necessary SMTP informations , that is your HOSTNAME , FROM ADDRESS and TO ADDRESS to the SMTP client.
- Sample Database and tables for Crystal Reports tutorials
- Step by Step help for creating a simple Crystal Reports in VB.NET
- VB.NET Crystal Reports from multiple tables
- VB.NET Crystal Reports String parameter
- VB.NET Crystal Reports Integer parameter
- VB.NET Crystal Reports Date parameter
- VB.NET Crystal Report Load Dynamically
- VB.NET Crystal Reports Formula Fields
- VB.NET Crystal Reports Summary Fields
- VB.NET Crystal Reports Export to PDF
- VB.NET Crystal Reports Export to Excel
- Crystal Reports Without Database
- Crystal Report from SQL Query String
- Dynamic Crystal Reports from SQL Query String
- Crystal Reports from XML File
- Create a Subreport in Crystal Reports
- Create a Subreport in Crystal Reports with Link
- How to deploy Crystal Reports on Clinet Machine
- How to create Crystal Reports installer using Merge Modules