Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a PDF file created by Crystal as an attachment

Status
Not open for further replies.

redheadpgr

Programmer
Feb 8, 2002
17
0
0
US
I'm using the following code to create a PDF file from a Crystal Report.

Code:
Dim oRpt As New CrystalReport1
Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions
oRpt.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
oRpt.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
filepath = "c:\crystal\report.pdf"

DiskOpts.DiskFileName = filepath
oRpt.ExportOptions.DestinationOptions = DiskOpts

oRpt.Export()

dim myMessage as New MailMessage
myMessage.To = "SomeEmail@somecompany.com"
myMessage.From = "Me@mycompany.com"
myMessage.Body = "See attached file"

myMessage.Attachments.Add(New MailAttachment(filepath, MailEncoding.UUEncode)

SmtpMail.SmtpServer = "myEmailServer"
SmtpMail.Send(myMessage)

This method works fine but I'm wondering if there is any way I can bypass exporting the file to disk? I still need to have the pdf file as an attachment.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top