?
Solved

Exporting a report to PDF then sending it via Email

Posted on 2003-11-14
7
Medium Priority
?
430 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

807 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