我希望能够使用我们的SQL数据库中的数据,使用VB.Net和Crystal Reports创建,命名和存储个性化报告(实际上是学校成绩单)。
最好能够使用存储在数据库中的电子邮件地址自动生成个性化电子邮件,附上上述PDF报告并将其发送出去。
之前有没有人尝试这样的事情?
任何帮助/指针的TIA!
答案 0 :(得分:1)
根据晶体的版本,导出功能看起来与此类似
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
“发送”部分将如下所示:
Dim email As New MailMessage()
''//set the reply to address and the to address
email.To.Add(New MailAddress("student@domain.com", "Studen Name"))
email.ReplyTo = New MailAddress("youremail@domain.com", "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