Solved

Exporting a report to PDF then sending it via Email

Posted on 2003-11-14
7
415 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Programmatically signing Word macros 4 61
WKHTMLTOPDF - --disable-smart-shrinking not working 10 37
Word Directory is not in the drop down list 4 25
Angular JS Route 3 52
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

17 Experts available now in Live!

Get 1:1 Help Now