Skip to Content
Former Member
Oct 19, 2007 at 05:04 PM

Exporting a crystal report as PDF and Attaching to an email via code - Filename Issuses?


Post Author: alynch

CA Forum: .NET

I need to export a crystal report as a pdf and send it out via email. I have created a subroutine that works but the attached filename come up as "untitled.txt" so the receiving machine believes it is a text file. If I rename it on the recipients machine to a ".pdf" I can open it with acrobat and it looks OK. Does anyone know how to rename the file as a pdf prior to sending it out?

Thank You.


I have included a copy of the subroutine:

Dim repdoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument()

Dim diskOpts As New CrystalDecisions.Shared.DiskFileDestinationOptions()

Dim ExpOpts As CrystalDecisions.Shared.ExportOptions

Dim MailOpts As New CrystalDecisions.Shared.MicrosoftMailDestinationOptions()

repdoc = Me.CrystalReport11

repdoc.Load("C:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\CrystalReport1.rpt")

ExpOpts = repdoc.ExportOptions

With ExpOpts

.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.MicrosoftMail

.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat

End With

With MailOpts

.MailMessage = "Message"

.MailToList = "enter email adress here"

.MailSubject = "Attached is a PDF file - .net Export test "

End With

ExpOpts.DestinationOptions = MailOpts



Catch err As Exception


End Try

End Sub