adders99
asked on
Exporting a report to PDF then sending it via Email
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
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
How are you creating your report?
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(Cry stalDecisi ons.Shared .ExportFor matType.Po rtableDocF ormat,
"c:\\myfile.pdf");
}
// 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(Cry
"c:\\myfile.pdf");
}
ASKER
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
So this ExportToDisk function doesnt prompt the user ?
cheers
Adam
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.
The method above does work, I tried it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent...I'll check it out tomorrow, and sign this one off. Many thanks mate !
Adam
Adam
ASKER
cool, that works great, many thanks. Just got to work out how to attach it now !
cheers
Adam
cheers
Adam