?
Solved

Exporting a report to PDF then sending it via Email

Posted on 2003-11-14
7
Medium Priority
?
428 Views
Last Modified: 2010-04-16
Hi guys,

    Ive managed to sort out my previous problem sending an Email from a non Web .NET application, but now I need to be able to export a report to a predetermined directory and name, without prompting the user with a dialog box. I then intent to attach it to the email and send it. Any ideas how this can be achieved in C# .NET ?

thanks

Adam
0
Comment
Question by:adders99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 2

Expert Comment

by:sedmans
ID: 9747730
How are you creating your report?
0
 
LVL 9

Expert Comment

by:Joeisanerd
ID: 9752460
I'm guessing your using the Crystal Reports that comes with Visual Studio, so add the report to the project then add a Crystal Reports Document to the form from the Components area, it will ask you which Report from your project you want to use. What this does is it creates a variable that you access through your forms code.  Then you can use the ExportToDisk feature, although you may not know when it does exporting, so hopefully it's a small report.

// This variable is created by Visual Studio when dragging the crystal report item from the
//components  section, it creates a variable from your report file.
private ReportTest.MyReport myReport1;

private void button1_Click(object sender, System.EventArgs e)
{
     // Self explanatory here
   myReport1.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
            "c:\\myfile.pdf");
}


0
 

Author Comment

by:adders99
ID: 9753779
Hi there, yup Im creating the report using Crystal Reports Enterprise, saving it away and storing it as a RPT file on the network. Then, when the user wants to produce it, they supply the parameters via a PB app, which in turns calls my c# app (tortuous path but Im picking up the pieces of an old system). This is a Windows Form app which uses the Crystal Reports in .NET to open it, export it or email.

So this ExportToDisk function doesnt prompt the user ?

cheers

Adam
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Joeisanerd
ID: 9754442
No it won't prompt the user for anything.  The only problem is that you have to have the report added to the project ahead of time.  Unfortunately this doesn't give you much flexibility for your reports, but I bet there is a way to use any crystal file and then exporttodisk.

The method above does work, I tried it.
0
 
LVL 9

Accepted Solution

by:
Joeisanerd earned 400 total points
ID: 9755129
Ok I found a slick solution that is much more dynamic

using CrystalDecisions.CrystalReports.Engine;

ReportDocument Report = new ReportDocument();
Report.Load("c:\\MyReport.rpt");
Report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
                  "c:\\myfile.pdf");
                  
This way you can specify the report at runtime and not design time. No user intervention
0
 

Author Comment

by:adders99
ID: 9757992
Excellent...I'll check it out tomorrow, and sign this one off. Many thanks mate !

Adam
0
 

Author Comment

by:adders99
ID: 9769799
cool, that works great, many thanks. Just got to work out how to attach it now !

cheers

Adam
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question