Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Email report directly from the Crystal viewer

Avatar of Éric Moreau
Éric MoreauFlag for Canada asked on
Crystal Reports.NET ProgrammingVisual Basic.NET
23 Comments1 Solution1606 ViewsLast Modified:

I am using Crystal Reports bundled with VS2008.

A client asked me to add a feature to e-mail the report he currently sees in the viewer. I looked around the properties of the viewer and saw nothing that does that.

So I have added a plain old button to my viewer form and pasted this code I found googling (I am not sure it is related to this version of CR):
    Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmail.Click
        Dim pdfOpts As PdfRtfWordFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions()
        Dim mailOpts As MicrosoftMailDestinationOptions = ExportOptions.CreateMicrosoftMailDestinationOptions()
        Dim exportOpts As ExportOptions = New ExportOptions

        pdfOpts.UsePageRange = False
        exportOpts.ExportFormatOptions = pdfOpts

        exportOpts.ExportDestinationOptions = mailOpts

        exportOpts.ExportDestinationType = ExportDestinationType.MicrosoftMail
        exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat

        With DirectCast(Me.Viewer.ReportSource, CrystalDecisions.CrystalReports.Engine.ReportDocument)
        End With
    End Sub

With this code, an "InvalidArgumentException" is raised on the .Export line. The Message is "Invalid export options".

Is this the correct way to e-mail the report? Is there another method?
Avatar of Éric Moreau
Éric MoreauFlag of Canada imageSenior .Net Consultant
This problem has been solved!
Unlock 1 Answer and 23 Comments.
See Answers