1. Create PDF programatically
Depending on the version of crystal, the export function will look similar to this
Dim objApp As CRAXDRT.Application
Dim objRpt As CRAXDRT.Report
Dim Path As String = "MyReport.rpt"
objApp = new CRAXDRT.Application
objRpt = objApp.OpenReport(Path)
With objRpt
.ExportOptions.FormatType = crEFTPortableDocFormat
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.DiskFileName = "MyReport.PDF"
.ExportOptions.PDFExportAllPages = True
.Export( False )
End With
2. Send email with a PDF attachment
The "send" part will look like this:
Dim email As New MailMessage()
''//set the reply to address and the to address
email.To.Add(New MailAddress("[email protected]", "Studen Name"))
email.ReplyTo = New MailAddress("[email protected]", "Your name")
''//Assign the MailMessage's properties
email.Subject = "Your scorecard file"
email.Body = "Attached is the file you asked<br />Regards!"
email.IsBodyHtml = True
''//attach the file
email.Attachments.Add(New Attachment("c:\temp\myreport.pdf"))
Dim smtp As New SmtpClient
Try
smtp.Send(email)
Catch ex As Exception
messageBox("cant send")
End Try