Solved

Exporting a report to PDF then sending it via Email

Posted on 2003-11-14
7
414 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 100 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now