Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

export crystal report to pdf then send to email using outlook

$
0
0

good day sir,

 

this is my whole code for creating a crystal report and exporting it to a pdf file:

 

Public Sub rsvrpt()

        Dim rpt As New reservationrpt() 'The report you created.

        Dim MyCommand As New SqlCommand()

        Dim myDA As New SqlDataAdapter()

        Dim myDS As New DataSet2() 'The DataSet you created.

        Dim cn As New SqlConnection(ConnectString())

 

 

        Try

 

 

            MyCommand.Connection = cn

            MyCommand.CommandText = "SELECT * FROM maintable where irsno=" + irsn + " And branchID='" + branch + "'"

            MyCommand.CommandType = CommandType.Text

            myDA.SelectCommand = MyCommand

            myDA.Fill(myDS, "maintable")

 

 

            'myDA.SelectCommand.CommandText = "Select fullname from usertbl where username='" + Login.txtuser.Text + "'"

            'myDA.Fill(myDS, "usertbl")

 

 

            myDA.SelectCommand.CommandText = "Select * from roomtbl where irsno=" + irsn + " And branchID='" + branch + "'"

            myDA.Fill(myDS, "roomtbl")

 

 

            myDS.EnforceConstraints = False

            rpt.SetDataSource(myDS)

            CrystalReportViewer1.ReportSource = rpt

            'rpt.PrintOptions.PrinterName = "EPSON LX-300+ /II"

            'rpt.PrintToPrinter(1, False, 0, 0)

        Catch Excep As Exception

            MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK,

            MessageBoxIcon.Error)

        End Try

 

 

      

        Try

            Dim CrExportOptions As ExportOptions

            Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()

            Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()

            CrDiskFileDestinationOptions.DiskFileName = "C:\Users\Frontliner0102\Desktop\reservation.pdf"

            CrExportOptions = rpt.ExportOptions

            With CrExportOptions

                .ExportDestinationType = ExportDestinationType.DiskFile

                .ExportFormatType = ExportFormatType.PortableDocFormat

                .DestinationOptions = CrDiskFileDestinationOptions

                .FormatOptions = CrFormatTypeOptions

            End With

            rpt.Export()

        Catch ex As Exception

        End Try

 

    End Sub

 

 

i want to send the crystal report to an email using microsoft outlook but i dont have any idea how to start it.can anyone give me some advice or guide on how to dot it? I searched throughout the internet but all i have read is that using SMPT server.


Viewing all articles
Browse latest Browse all 3636

Trending Articles



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