using System; using System.Windows.Forms; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.Web.Mail; namespace WindowsApplication1 { public partial class Form1 : Form { ReportDocument cryRpt; string pdfFile = "c:\\csharp.net-informations. pdf"; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { cryRpt = new ReportDocument(); cryRpt.Load(PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt"); crystalReportViewer1. ReportSource = cryRpt; crystalReportViewer1.Refresh() ; } private void button2_Click(object sender, EventArgs e) { try { ExportOptions CrExportOptions ; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions. DiskFileName = pdfFile; CrExportOptions = cryRpt.ExportOptions; CrExportOptions. ExportDestinationType = ExportDestinationType. DiskFile; CrExportOptions. ExportFormatType = ExportFormatType. PortableDocFormat; CrExportOptions. DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; cryRpt.Export(); sendmail(); } catch (Exception ex) { MessageBox.Show(ex.ToString()) ; } } private void sendmail() { try { SmtpMail.SmtpServer.Insert(0, "your hostname"); MailMessage Msg = new MailMessage(); Msg.To = "to address here"; Msg.From = "from address here"; Msg.Subject = "Crystal Report Attachment "; Msg.Body = "Crystal Report Attachment "; Msg.Attachments.Add(new MailAttachment(pdfFile)); System.Web.Mail.SmtpMail.Send( Msg); } catch (Exception ex) { MessageBox.Show (ex.ToString()); } } } }
Breaking News
Editors Picks
Wednesday, February 22, 2012
Email Crystal Reports from C# Application
Subscribe to:
Posts
(
Atom
)
Topics
.NET Error
AJAX and Java Script
ASP.NET
Asp.net Interview Question And Answer
aspx page to pdf
C#
C# Interview Question And Answer
C#.Oracle
CSS
Data List
Dynamic Controls
Excel
Google Map Api
Grid View
HINDI
IIS
Microsoft Certifications
MS Chart
my sql
OOPS
Oracle
Security
Send Email
Send SMS
SQL SERVER
State management
Webconfig
Windows
Windows Services
WPF
XML