Solved

Exporting a report to PDF then sending it via Email

Posted on 2003-11-14
7
420 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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