We have software like doPdf which prints without necessarily giving hard copy output. can somebody send me a code that can print a crystal report with a printer without giving physical output which will enable me save the file with a given name before sending it via E-mail.

Maybe this will help:

Imports System.Windows.Forms
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Namespace WindowsApplication1
	Public Partial Class Form1
		Inherits Form
		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub button1_Click(sender As Object, e As EventArgs)
			Dim cryRpt As New ReportDocument()
			cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")

			Dim crtableLogoninfos As New TableLogOnInfos()
			Dim crtableLogoninfo As New TableLogOnInfo()
			Dim crConnectionInfo As New ConnectionInfo()
			Dim CrTables As Tables

			crConnectionInfo.ServerName = "YOUR SERVERNAME"
			crConnectionInfo.DatabaseName = "DATABASE NAME"
			crConnectionInfo.UserID = "USERID"
			crConnectionInfo.Password = "PASSWORD"

			CrTables = cryRpt.Database.Tables
			For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
				crtableLogoninfo = CrTable.LogOnInfo
				crtableLogoninfo.ConnectionInfo = crConnectionInfo
				CrTable.ApplyLogOnInfo(crtableLogoninfo)
			Next

			cryRpt.Refresh()
			cryRpt.PrintToPrinter(1, True, 0, 0)

		End Sub
	End Class
End Namespace
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.