C
crjunk
Currently I have a Crystal Report that automatically loads as a PDF in
the browser whenever the user views the report. This is working great.
What I would like to do is add code that automatically email this
report to a specific address whenever the report is viewed. Is this
possible? Here is the code that I'm currently using to view the report
as a PDF.
Private Sub LoadReport()
If Session("LoggedIn") = True Then
Dim tmpFileName As String
Dim myDataSet As New DataSet
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
Dim FName, MyName As String
tmpFileName = Trim(Request.QueryString("fn"))
tmpFileName = Trim(tmpFileName) & ".xml"
CRViewer.Visible = True
oRpt.Load(Server.MapPath(".") & "\MPRInvoice.rpt")
'Read the XML file using the ReadXml method
myDataSet.ReadXml("C:\XML\" & Trim(tmpFileName))
oRpt.SetDataSource(myDataSet)
oRpt.ExportOptions.ExportDestinationType =
CrystalDecisions.[Shared].ExportDestinationType.DiskFile
oRpt.ExportOptions.ExportFormatType =
CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
FName = "C:\XML\" & Session.SessionID.ToString.Trim &
".pdf"
DiskOpts.DiskFileName = "C:\XML\" &
Session.SessionID.ToString.Trim & ".pdf"
MyName = DiskOpts.DiskFileName
oRpt.ExportOptions.DestinationOptions = DiskOpts
oRpt.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(FName)
Response.Flush()
Response.Close()
System.IO.File.Delete(FName)
Else
Response.Write("<font face='Arial, Helvetica,
sans-serif'><div align='center'><b>You are no longer logged into the
system.</b></div></font>")
End If
End Sub
I thought there might be a temporary PDF file in the C:\XML\ directory,
but no such luck. If a physical pdf file is being created in this
directory, I cannot see it before it gets deleted.
Thanks,
CR Junk
the browser whenever the user views the report. This is working great.
What I would like to do is add code that automatically email this
report to a specific address whenever the report is viewed. Is this
possible? Here is the code that I'm currently using to view the report
as a PDF.
Private Sub LoadReport()
If Session("LoggedIn") = True Then
Dim tmpFileName As String
Dim myDataSet As New DataSet
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
Dim FName, MyName As String
tmpFileName = Trim(Request.QueryString("fn"))
tmpFileName = Trim(tmpFileName) & ".xml"
CRViewer.Visible = True
oRpt.Load(Server.MapPath(".") & "\MPRInvoice.rpt")
'Read the XML file using the ReadXml method
myDataSet.ReadXml("C:\XML\" & Trim(tmpFileName))
oRpt.SetDataSource(myDataSet)
oRpt.ExportOptions.ExportDestinationType =
CrystalDecisions.[Shared].ExportDestinationType.DiskFile
oRpt.ExportOptions.ExportFormatType =
CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
FName = "C:\XML\" & Session.SessionID.ToString.Trim &
".pdf"
DiskOpts.DiskFileName = "C:\XML\" &
Session.SessionID.ToString.Trim & ".pdf"
MyName = DiskOpts.DiskFileName
oRpt.ExportOptions.DestinationOptions = DiskOpts
oRpt.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(FName)
Response.Flush()
Response.Close()
System.IO.File.Delete(FName)
Else
Response.Write("<font face='Arial, Helvetica,
sans-serif'><div align='center'><b>You are no longer logged into the
system.</b></div></font>")
End If
End Sub
I thought there might be a temporary PDF file in the C:\XML\ directory,
but no such luck. If a physical pdf file is being created in this
directory, I cannot see it before it gets deleted.
Thanks,
CR Junk