Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello All,

I am using C# , crystal report to populate the report and Reportviewer to show the report.

Now I need to know how to email that report which is generated on report viewer.

I searched the same in google but I found all code where it need physical path of report file. but I have added them into project and used name of crystal report.

Let me know if this is unclear to you.
Posted
Comments
Sandeep Mewara 15-May-12 10:50am    
Email report in PDF format?

1 solution

This is actually pretty easy, depending on the version of Crystal you use.
You need a ReportDocument[^] (which you probably have if you have a viewer) and use the ExportToStream[^] function.
Now simply pass the Stream[^] to the constructor of an Attachment[^].
Other than that you can simply use the MailMessage[^] and SmtpClient[^] like you would for any other mail.
Using this method does not require you to save the report to disk (not even temporarily).
Hope it helps!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900