如何从Crystal报表中导出PDF文件并保存到网站的本地文件夹中,并以电子邮件附件的形式发送 [英] How to Export PDF file from Crystal report and save into Local folder of website and Send in Email Attachment

查看:139
本文介绍了如何从Crystal报表中导出PDF文件并保存到网站的本地文件夹中,并以电子邮件附件的形式发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Helloo,

我想了解以PDF格式导出水晶报表以及将导出文件直接保存在我们的网站本地文件夹中,并通过SMTP作为附件发送电子邮件的情况.

我尝试只制作PDF,但没有成功将其保存到我们的本地文件夹中,以及将该PDF文件的附件发送到SMTP代码中.

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

推荐答案

嗨Mitesh,

看看以下链接,
http://csharp.net-informations.com/crystal-reports/csharp- crystal-reports-email.htm [ ^ ]
http://social.msdn.microsoft.com/Forums/eu/vscrystalreports/thread/2f37947e-34da-4459-b17b-c484da40d887 [ http://www.c -sharpcorner.com/UploadFile/17e8f6/creating-crystal-report-and-send-via-mail-in-Asp-Net/ [
Hi Mitesh,

Have a look at following links,
http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-email.htm[^]
http://social.msdn.microsoft.com/Forums/eu/vscrystalreports/thread/2f37947e-34da-4459-b17b-c484da40d887[^]
http://www.c-sharpcorner.com/UploadFile/17e8f6/creating-crystal-report-and-sending-via-mail-in-Asp-Net/[^]

Hope this helps you.

Regards,
Vani


导出到文件夹时可能是权限问题.
您可以尝试将temp文件夹用作

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.


这篇关于如何从Crystal报表中导出PDF文件并保存到网站的本地文件夹中,并以电子邮件附件的形式发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆