Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#CrystalReports
Helloo,
 
i want to know about the Export the crystal report in PDF formate as well as direct save that export file in our website local folder and send in email as attachment via SMTP.
 
i tried and make PDF only but not success into save in our local folder as well as send as attachment of that PDF file into SMTP code.
 
 
 protected void Page_Init(object sender, EventArgs e)
    {
        string id;
        id = Request.QueryString["id"];
        c.setcon();
        String data = "SELECT  * from Leave_record where id=" + id + "";
        SqlDataAdapter ad1 = new SqlDataAdapter(data, c.getcon());
        DataSet ds1 = new DataSet();
        ad1.Fill(ds1);
 
        path = Server.MapPath("REPORTS/leave_report.rpt");
        cr = new ReportDocument();
        cr.Load(path);
 
        cr.SetDataSource(ds1.Tables[0]);
 
        string name=Server.MapPath("PDF/mitesh.pdf");
        cr.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false,name); // only show PDF file but not save in Website Folder
        CrystalReportViewer1.ReportSource = cr;
}
 
Please help me.
 
Thanks and Regards...
Mitesh
Posted 2-Jul-12 18:54pm
Edited 2-Jul-12 19:44pm
v2
Comments
Damith Weerasinghe at 3-Jul-12 1:42am
   
can you show the code what you have tried so far?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

May be permission issue when exporting to a folder.
You can try using temp folder as
 
string fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".pdf";
 
then save to temp folder
 
reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, fileName);
 
since you have the file location you can attach that to a Email.
  Permalink  
v2
Comments
Damith Weerasinghe at 3-Jul-12 2:40am
   
I'm glad it helped you :)

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 450
1 Sergey Alexandrovich Kryukov 350
2 Shai Vashdi 318
3 OriginalGriff 265
4 Peter Leow 171
0 Sergey Alexandrovich Kryukov 9,109
1 OriginalGriff 5,290
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid