I want to be able to export the report to pdf and send it as an attachment without having to save the pdf to disk first.
Below is my code so far:
Code: Select all
Private Sub SendReport()
Dim stream As IO.MemoryStream
Dim smtp As Mail.SmtpClient
Dim item As Mail.MailMessage
Dim attachment As Mail.Attachment
Dim report As Stimulsoft.Report.StiReport
Try
'Get Report
report = StiWebViewer.Report
'Create Mail Message
item = New Mail.MailMessage("", "")
item.Subject = "Test Report"
item.Body = "Attached is a report."
'Create Attachment
stream = New IO.MemoryStream
report.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, stream)
attachment = New Mail.Attachment(stream, "MyReport.pdf", "application/pdf")
item.Attachments.Add(attachment)
'Create SMTP Client
smtp = New Mail.SmtpClient
smtp.Host = ""
smtp.Send(item)
Catch ex As Exception
lblError.Text = "An error occured while trying to generate report."
End Try
End Sub
Any ideas on how I best go about this?